summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-06-01 19:28:26 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-06-01 21:31:57 +1000
commitc9136538b5cd2d86c90ed0921ba5f716f3cb6d85 (patch)
tree0a6763bfffc056f2d64c35eeabdc8434a33ece58 /pkg
parentcaab31ff38b4bd1ee7172e24a7ee3dcd8681be33 (diff)
Refresh commits viewport on focus lost
We don't want the highlighted selection sticking around after the context loses focus.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/context/list_context_trait.go8
-rw-r--r--pkg/gui/context/local_commits_context.go8
-rw-r--r--pkg/gui/context/sub_commits_context.go8
3 files changed, 14 insertions, 10 deletions
diff --git a/pkg/gui/context/list_context_trait.go b/pkg/gui/context/list_context_trait.go
index e001bd3a7..e993719d5 100644
--- a/pkg/gui/context/list_context_trait.go
+++ b/pkg/gui/context/list_context_trait.go
@@ -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)
}
diff --git a/pkg/gui/context/local_commits_context.go b/pkg/gui/context/local_commits_context.go
index 75c2a58fb..74363c52f 100644
--- a/pkg/gui/context/local_commits_context.go
+++ b/pkg/gui/context/local_commits_context.go
@@ -67,10 +67,10 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
Kind: types.SIDE_CONTEXT,
Focusable: true,
})),
- list: viewModel,
- getDisplayStrings: getDisplayStrings,
- c: c,
- refreshViewportOnLineFocus: true,
+ list: viewModel,
+ getDisplayStrings: getDisplayStrings,
+ c: c,
+ refreshViewportOnChange: true,
},
}
}
diff --git a/pkg/gui/context/sub_commits_context.go b/pkg/gui/context/sub_commits_context.go
index a88d96e08..e2c89aa14 100644
--- a/pkg/gui/context/sub_commits_context.go
+++ b/pkg/gui/context/sub_commits_context.go
@@ -72,10 +72,10 @@ func NewSubCommitsContext(
Focusable: true,
Transient: true,
})),
- list: viewModel,
- getDisplayStrings: getDisplayStrings,
- c: c,
- refreshViewportOnLineFocus: true,
+ list: viewModel,
+ getDisplayStrings: getDisplayStrings,
+ c: c,
+ refreshViewportOnChange: true,
},
}
}