diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-25 08:34:02 +1000 |
---|---|---|
committer | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2020-08-24 22:39:01 +0000 |
commit | 771e87ebeb97dbace95f9cdb16202ce30129157c (patch) | |
tree | a72111b36118dce225145b0961e4b39358d9dfe7 /pkg/gui/files_panel.go | |
parent | 2598ce1d4b708d01595ddfdd4ae6ec3132a9266b (diff) |
do not reset cursor unless previous file has moved position
Diffstat (limited to 'pkg/gui/files_panel.go')
-rw-r--r-- | pkg/gui/files_panel.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index f983f5033..9861e0cd6 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -397,6 +397,7 @@ func (gui *Gui) refreshStateFiles() error { // when we refresh, go looking for a matching name // move the cursor to there. selectedFile := gui.getSelectedFile() + prevSelectedLineIdx := gui.State.Panels.Files.SelectedLineIdx // get files to stage files := gui.GitCommand.GetStatusFiles(commands.GetStatusFileOptions{}) @@ -407,10 +408,13 @@ func (gui *Gui) refreshStateFiles() error { } // let's try to find our file again and move the cursor to that - for idx, f := range gui.State.Files { - if selectedFile != nil && f.Matches(selectedFile) { - gui.State.Panels.Files.SelectedLineIdx = idx - break + if selectedFile != nil { + for idx, f := range gui.State.Files { + selectedFileHasMoved := f.Matches(selectedFile) && idx != prevSelectedLineIdx + if selectedFileHasMoved { + gui.State.Panels.Files.SelectedLineIdx = idx + break + } } } |