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:
// 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.
refreshViewportOnLineFocus bool
refreshViewportOnChange bool
}
func (self *ListContextTrait) IsListContext() {}
@ -34,7 +34,7 @@ func (self *ListContextTrait) FocusLine() {
self.GetViewTrait().FocusPoint(self.list.GetSelectedLineIdx())
self.setFooter()
if self.refreshViewportOnLineFocus {
if self.refreshViewportOnChange {
self.refreshViewport()
}
}
@ -65,6 +65,10 @@ func (self *ListContextTrait) HandleFocus(opts types.OnFocusOpts) error {
func (self *ListContextTrait) HandleFocusLost(opts types.OnFocusLostOpts) error {
self.GetViewTrait().SetOriginX(0)
if self.refreshViewportOnChange {
self.refreshViewport()
}
return self.Context.HandleFocusLost(opts)
}