mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-17 21:18:31 +02:00
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
This commit is contained in:
commit
9514284f8e
@ -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()
|
||||
}})
|
||||
}
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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
|
||||
},
|
||||
})
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user