Skip to content

Commit

Permalink
Don't render staging view when it loses focus
Browse files Browse the repository at this point in the history
As far as I understand, this was needed back when the staging context was still
responsible for rendering its highlight (as opposed to the gocui view, as it is
today). It was necessary to call it with isFocused=false so that it removed the
highlight. The isFocused bool is no longer used today (and we'll remove it in
the next commit), so there's no need to render the view here any more.

This fixes flickering when leaving the staging view by pressing escape. The
reason is that in this case the patch state was already set to nil by the time
we get here, so we would render an empty view for a brief moment.

On top of that, it fixes unwanted scrolling to the top when leaving the staging
view. The reason for this is that we have code in layout that scrolls views up
if needed, e.g. because the window got taller or the view content got shorter
(added in jesseduffield#3839). This kicked in because we emptied the view, and scrolled it
all the way to the top, which we don't want.
  • Loading branch information
stefanhaller committed Oct 18, 2024
1 parent eaf3bf0 commit 8f3e59b
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions pkg/gui/controllers/staging_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ func (self *StagingController) GetOnFocusLost() func(types.OnFocusLostOpts) {
if opts.NewContextKey != self.otherContext.GetKey() {
self.c.Views().Staging.Wrap = true
self.c.Views().StagingSecondary.Wrap = true
self.c.Contexts().Staging.Render(false)
self.c.Contexts().StagingSecondary.Render(false)
}
}
}
Expand Down

0 comments on commit 8f3e59b

Please sign in to comment.