summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-05-13 12:29:17 +0200
committerGitHub <noreply@github.com>2023-05-13 12:29:17 +0200
commit9514284f8e9f669b32d09af81de57d2bd232fff1 (patch)
tree918ca07409b44a36b43a32b25a089d1cb9600f82
parentece14844bb7e95fa0331d5e9f15cb006e1f2ec20 (diff)
parente5dd4d311064c2b45dfe3f08a2a4cbf4536404cc (diff)
Merge pull request #2608 from stefanhaller/allow-selected-line-outside-view
Allow the selected line of a list view to be outside the visible area
-rw-r--r--pkg/gui/controllers/filtering_menu_action.go1
-rw-r--r--pkg/gui/controllers/list_controller.go16
-rw-r--r--pkg/gui/controllers/stash_controller.go1
-rw-r--r--pkg/gui/layout.go2
-rw-r--r--pkg/integration/tests/filter_by_path/select_file.go4
-rw-r--r--pkg/integration/tests/filter_by_path/shared.go2
6 files changed, 7 insertions, 19 deletions
diff --git a/pkg/gui/controllers/filtering_menu_action.go b/pkg/gui/controllers/filtering_menu_action.go
index 7c9de7973..f815d5b3f 100644
--- a/pkg/gui/controllers/filtering_menu_action.go
+++ b/pkg/gui/controllers/filtering_menu_action.go
@@ -74,5 +74,6 @@ func (self *FilteringMenuAction) setFiltering(path string) error {
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() {
self.c.Contexts().LocalCommits.SetSelectedLineIdx(0)
+ self.c.Contexts().LocalCommits.FocusLine()
}})
}
diff --git a/pkg/gui/controllers/list_controller.go b/pkg/gui/controllers/list_controller.go
index 0a6de821a..1ca3a1e12 100644
--- a/pkg/gui/controllers/list_controller.go
+++ b/pkg/gui/controllers/list_controller.go
@@ -54,12 +54,6 @@ func (self *ListController) HandleScrollUp() error {
scrollHeight := self.c.UserConfig.Gui.ScrollHeight
self.context.GetViewTrait().ScrollUp(scrollHeight)
- // we only need to do a line change if our line has been pushed out of the viewport, because
- // at the moment much logic depends on the selected line always being visible
- if !self.isSelectedLineInViewPort() {
- return self.handleLineChange(-scrollHeight)
- }
-
return nil
}
@@ -67,19 +61,9 @@ func (self *ListController) HandleScrollDown() error {
scrollHeight := self.c.UserConfig.Gui.ScrollHeight
self.context.GetViewTrait().ScrollDown(scrollHeight)
- if !self.isSelectedLineInViewPort() {
- return self.handleLineChange(scrollHeight)
- }
-
return nil
}
-func (self *ListController) isSelectedLineInViewPort() bool {
- selectedLineIdx := self.context.GetList().GetSelectedLineIdx()
- startIdx, length := self.context.GetViewTrait().ViewPortYBounds()
- return selectedLineIdx >= startIdx && selectedLineIdx < startIdx+length
-}
-
func (self *ListController) scrollHorizontal(scrollFunc func()) error {
scrollFunc()
diff --git a/pkg/gui/controllers/stash_controller.go b/pkg/gui/controllers/stash_controller.go
index 3e1b65ce8..4b5135884 100644
--- a/pkg/gui/controllers/stash_controller.go
+++ b/pkg/gui/controllers/stash_controller.go
@@ -187,6 +187,7 @@ func (self *StashController) handleRenameStashEntry(stashEntry *models.StashEntr
return err
}
self.context().SetSelectedLineIdx(0) // Select the renamed stash
+ self.context().FocusLine()
return nil
},
})
diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go
index 5b3e6845f..35dbe55b7 100644
--- a/pkg/gui/layout.go
+++ b/pkg/gui/layout.go
@@ -131,8 +131,6 @@ func (gui *Gui) layout(g *gocui.Gui) error {
continue
}
- listContext.FocusLine()
-
view.SelBgColor = theme.GocuiSelectedLineBgColor
// I doubt this is expensive though it's admittedly redundant after the first render
diff --git a/pkg/integration/tests/filter_by_path/select_file.go b/pkg/integration/tests/filter_by_path/select_file.go
index 6c1243dc8..80a69a2b4 100644
--- a/pkg/integration/tests/filter_by_path/select_file.go
+++ b/pkg/integration/tests/filter_by_path/select_file.go
@@ -18,10 +18,12 @@ var SelectFile = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Commits().
Focus().
Lines(
- Contains(`only filterFile`).IsSelected(),
+ Contains(`none of the two`).IsSelected(),
+ Contains(`only filterFile`),
Contains(`only otherFile`),
Contains(`both files`),
).
+ SelectNextItem().
PressEnter()
// when you click into the commit itself, you see all files from that commit
diff --git a/pkg/integration/tests/filter_by_path/shared.go b/pkg/integration/tests/filter_by_path/shared.go
index 93e5e0a3d..675a2d9df 100644
--- a/pkg/integration/tests/filter_by_path/shared.go
+++ b/pkg/integration/tests/filter_by_path/shared.go
@@ -14,6 +14,8 @@ func commonSetup(shell *Shell) {
shell.UpdateFileAndAdd("filterFile", "new filterFile content")
shell.Commit("only filterFile")
+
+ shell.EmptyCommit("none of the two")
}
func postFilterTest(t *TestDriver) {