From 8f3e59b78ed62c792d37843dbb4b32bf31ebbbd7 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 17 Oct 2024 09:41:33 +0200 Subject: [PATCH] Don't render staging view when it loses focus 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 #3839). This kicked in because we emptied the view, and scrolled it all the way to the top, which we don't want. --- pkg/gui/controllers/staging_controller.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/gui/controllers/staging_controller.go b/pkg/gui/controllers/staging_controller.go index 769cba68a23..4ae9a946b45 100644 --- a/pkg/gui/controllers/staging_controller.go +++ b/pkg/gui/controllers/staging_controller.go @@ -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) } } }