1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-10 22:42:00 +02:00

Refresh commits viewport on focus lost

We don't want the highlighted selection sticking around after the context loses focus.
This commit is contained in:
Jesse Duffield
2023-06-01 19:28:26 +10:00
parent caab31ff38
commit c9136538b5
3 changed files with 14 additions and 10 deletions

View File

@@ -21,7 +21,7 @@ type ListContextTrait struct {
// TODO: now that we allow scrolling, we should be smarter about what gets refreshed: // TODO: now that we allow scrolling, we should be smarter about what gets refreshed:
// we should find out exactly which lines are now part of the path and refresh those. // we should find out exactly which lines are now part of the path and refresh those.
// We should also keep track of the previous path and refresh those lines too. // We should also keep track of the previous path and refresh those lines too.
refreshViewportOnLineFocus bool refreshViewportOnChange bool
} }
func (self *ListContextTrait) IsListContext() {} func (self *ListContextTrait) IsListContext() {}
@@ -34,7 +34,7 @@ func (self *ListContextTrait) FocusLine() {
self.GetViewTrait().FocusPoint(self.list.GetSelectedLineIdx()) self.GetViewTrait().FocusPoint(self.list.GetSelectedLineIdx())
self.setFooter() self.setFooter()
if self.refreshViewportOnLineFocus { if self.refreshViewportOnChange {
self.refreshViewport() self.refreshViewport()
} }
} }
@@ -65,6 +65,10 @@ func (self *ListContextTrait) HandleFocus(opts types.OnFocusOpts) error {
func (self *ListContextTrait) HandleFocusLost(opts types.OnFocusLostOpts) error { func (self *ListContextTrait) HandleFocusLost(opts types.OnFocusLostOpts) error {
self.GetViewTrait().SetOriginX(0) self.GetViewTrait().SetOriginX(0)
if self.refreshViewportOnChange {
self.refreshViewport()
}
return self.Context.HandleFocusLost(opts) return self.Context.HandleFocusLost(opts)
} }

View File

@@ -67,10 +67,10 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
Kind: types.SIDE_CONTEXT, Kind: types.SIDE_CONTEXT,
Focusable: true, Focusable: true,
})), })),
list: viewModel, list: viewModel,
getDisplayStrings: getDisplayStrings, getDisplayStrings: getDisplayStrings,
c: c, c: c,
refreshViewportOnLineFocus: true, refreshViewportOnChange: true,
}, },
} }
} }

View File

@@ -72,10 +72,10 @@ func NewSubCommitsContext(
Focusable: true, Focusable: true,
Transient: true, Transient: true,
})), })),
list: viewModel, list: viewModel,
getDisplayStrings: getDisplayStrings, getDisplayStrings: getDisplayStrings,
c: c, c: c,
refreshViewportOnLineFocus: true, refreshViewportOnChange: true,
}, },
} }
} }