diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-03-21 09:06:15 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-03-30 21:57:00 +1100 |
commit | 1183f68e19d26a63293cfab1650a59f3b90a844b (patch) | |
tree | 95ee6e17f8168f008a0926464cbfcdbf8567f5d3 /pkg/commands/loading_files.go | |
parent | da6fe01eca531635c09627c60bd38d49bb092906 (diff) |
better handling of refreshed files
Diffstat (limited to 'pkg/commands/loading_files.go')
-rw-r--r-- | pkg/commands/loading_files.go | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/pkg/commands/loading_files.go b/pkg/commands/loading_files.go index ba3244999..d3757b179 100644 --- a/pkg/commands/loading_files.go +++ b/pkg/commands/loading_files.go @@ -102,38 +102,3 @@ func (c *GitCommand) GitStatus(opts GitStatusOptions) (string, error) { return strings.Join(splitLines, "\n"), nil } - -// MergeStatusFiles merge status files -func (c *GitCommand) MergeStatusFiles(oldFiles, newFiles []*models.File, selectedFile *models.File) []*models.File { - if len(oldFiles) == 0 { - return newFiles - } - - appendedIndexes := []int{} - - // retain position of files we already could see - result := []*models.File{} - for _, oldFile := range oldFiles { - for newIndex, newFile := range newFiles { - if utils.IncludesInt(appendedIndexes, newIndex) { - continue - } - // if we just staged B and in doing so created 'A -> B' and we are currently have oldFile: A and newFile: 'A -> B', we want to wait until we come across B so the our cursor isn't jumping anywhere - waitForMatchingFile := selectedFile != nil && newFile.IsRename() && !selectedFile.IsRename() && newFile.Matches(selectedFile) && !oldFile.Matches(selectedFile) - - if oldFile.Matches(newFile) && !waitForMatchingFile { - result = append(result, newFile) - appendedIndexes = append(appendedIndexes, newIndex) - } - } - } - - // append any new files to the end - for index, newFile := range newFiles { - if !utils.IncludesInt(appendedIndexes, index) { - result = append(result, newFile) - } - } - - return result -} |