summaryrefslogtreecommitdiffstats
path: root/pkg/gui/controllers/screen_mode_actions.go
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-06-23 13:13:58 +0200
committerGitHub <noreply@github.com>2024-06-23 13:13:58 +0200
commitcf40a5b077343cf6cf3de50b60fc4b47ce929dc1 (patch)
treeb27de3b227276cf54d39238e8162b79eb029567e /pkg/gui/controllers/screen_mode_actions.go
parenta62a5089d6ed5ba989279590a5bd3426829c856d (diff)
parent26132cf5bdae7ec81e9a0708c722ad2a9cf0c2cf (diff)
Improve render performance (#3686)
- **PR Description** Fix a performance regression that I introduced with v0.41: when entering or leaving staging mode for a file, or when switching from a file that has only unstaged changes to one that has both staged and unstaged changes, there was a noticeable lag of about 500ms on my machine. With the improvements in this PR we get this back down to about 20ms.
Diffstat (limited to 'pkg/gui/controllers/screen_mode_actions.go')
-rw-r--r--pkg/gui/controllers/screen_mode_actions.go27
1 files changed, 26 insertions, 1 deletions
diff --git a/pkg/gui/controllers/screen_mode_actions.go b/pkg/gui/controllers/screen_mode_actions.go
index 1db27f2e2..2d0026793 100644
--- a/pkg/gui/controllers/screen_mode_actions.go
+++ b/pkg/gui/controllers/screen_mode_actions.go
@@ -1,6 +1,7 @@
package controllers
import (
+ "github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
@@ -16,7 +17,7 @@ func (self *ScreenModeActions) Next() error {
),
)
- return nil
+ return self.rerenderViewsWithScreenModeDependentContent()
}
func (self *ScreenModeActions) Prev() error {
@@ -27,9 +28,33 @@ func (self *ScreenModeActions) Prev() error {
),
)
+ return self.rerenderViewsWithScreenModeDependentContent()
+}
+
+// these views need to be re-rendered when the screen mode changes. The commits view,
+// for example, will show authorship information in half and full screen mode.
+func (self *ScreenModeActions) rerenderViewsWithScreenModeDependentContent() error {
+ for _, context := range self.c.Context().AllList() {
+ if context.NeedsRerenderOnWidthChange() == types.NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_SCREEN_MODE_CHANGES {
+ if err := self.rerenderView(context.GetView()); err != nil {
+ return err
+ }
+ }
+ }
+
return nil
}
+func (self *ScreenModeActions) rerenderView(view *gocui.View) error {
+ context, ok := self.c.Helpers().View.ContextForView(view.Name())
+ if !ok {
+ self.c.Log.Errorf("no context found for view %s", view.Name())
+ return nil
+ }
+
+ return context.HandleRender()
+}
+
func nextIntInCycle(sl []types.WindowMaximisation, current types.WindowMaximisation) types.WindowMaximisation {
for i, val := range sl {
if val == current {