mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-09-16 09:16:26 +02:00
Rerender fewer views when their width changes
Ind5b4f7bb3e
and58a83b0862
we introduced a combined mechanism for rerendering views when either their width changes (needed for the branches view which truncates long branch names), or the screen mode (needed for those views that display more information in half or full screen mode, e.g. the commits view). This was a bad idea, because it unnecessarily rerenders too many views when just their width changes, which causes a noticable lag. This is a problem, for example, when selecting a file in the files panel that has only unstaged changes, and then going to one that has both staged and unstaged changes; this splits the main view, causing the side panels to become a bit narrower, and rerendering all those views took almost 500ms on my machine. Another similar example is entering or leaving staging mode. Fix this by being more specific about which views need rerendering under what conditions; this improves the time it takes to rerender in the above scenarios from 450-500s down to about 20ms. This reintroduces the code that was removed in58a83b0862
, but in a slightly different way.
This commit is contained in:
@@ -39,6 +39,18 @@ type ParentContexter interface {
|
||||
GetParentContext() (Context, bool)
|
||||
}
|
||||
|
||||
type NeedsRerenderOnWidthChangeLevel int
|
||||
|
||||
const (
|
||||
// view doesn't render differently when its width changes
|
||||
NEEDS_RERENDER_ON_WIDTH_CHANGE_NONE NeedsRerenderOnWidthChangeLevel = iota
|
||||
// view renders differently when its width changes. An example is a view
|
||||
// that truncates long lines to the view width, e.g. the branches view
|
||||
NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_WIDTH_CHANGES
|
||||
// view renders differently only when the screen mode changes
|
||||
NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_SCREEN_MODE_CHANGES
|
||||
)
|
||||
|
||||
type IBaseContext interface {
|
||||
HasKeybindings
|
||||
ParentContexter
|
||||
@@ -60,8 +72,8 @@ type IBaseContext interface {
|
||||
// determined independently.
|
||||
HasControlledBounds() bool
|
||||
|
||||
// true if the view needs to be rerendered when its width changes
|
||||
NeedsRerenderOnWidthChange() bool
|
||||
// to what extent the view needs to be rerendered when its width changes
|
||||
NeedsRerenderOnWidthChange() NeedsRerenderOnWidthChangeLevel
|
||||
|
||||
// true if the view needs to be rerendered when its height changes
|
||||
NeedsRerenderOnHeightChange() bool
|
||||
|
Reference in New Issue
Block a user