diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-02 01:31:23 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-02 11:09:12 +1100 |
commit | f7772f00c47a2ea2853abd37b4a9c25dcbb78a95 (patch) | |
tree | 0a456904a43e44d0bf59f45fe0425bb3e20aefd3 /pkg/gui/files_panel.go | |
parent | 216b5341ae1a5244449bdb5d93aea9581def2b68 (diff) |
do not jump cursor around when fixing merge conflicts
Diffstat (limited to 'pkg/gui/files_panel.go')
-rw-r--r-- | pkg/gui/files_panel.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index f872b8ab2..f7edb2b25 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -554,7 +554,22 @@ func (gui *Gui) refreshStateFiles() error { if selectedNode != nil { newIdx := gui.findNewSelectedIdx(prevNodes[prevSelectedLineIdx:], gui.State.FileManager.GetAllItems()) if newIdx != -1 && newIdx != prevSelectedLineIdx { - gui.State.Panels.Files.SelectedLineIdx = newIdx + newNode := gui.State.FileManager.GetItemAtIndex(newIdx) + // when not in tree mode, we show merge conflict files at the top, so you + // can work through them one by one without having to sift through a large + // set of files. If you have just fixed the merge conflicts of a file, we + // actually don't want to jump to that file's new position, because that + // file will now be ages away amidst the other files without merge + // conflicts: the user in this case would rather work on the next file + // with merge conflicts, which will have moved up to fill the gap left by + // the last file, meaning the cursor doesn't need to move at all. + leaveCursor := !gui.State.FileManager.InTreeMode() && newNode != nil && + selectedNode.File != nil && selectedNode.File.HasMergeConflicts && + newNode.File != nil && !newNode.File.HasMergeConflicts + + if !leaveCursor { + gui.State.Panels.Files.SelectedLineIdx = newIdx + } } } |