1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-24 05:36:19 +02:00

bring merge conflicts to top

This commit is contained in:
Jesse Duffield 2021-03-21 09:57:13 +11:00
parent fe4e305410
commit 4782d8aa1f
2 changed files with 7 additions and 4 deletions

View File

@ -2,7 +2,6 @@ package gui
import (
"fmt"
"sort"
"strings"
"github.com/jesseduffield/lazygit/pkg/commands/models"
@ -58,9 +57,6 @@ func (m *StatusLineManager) GetAllFiles() []*models.File {
func (m *StatusLineManager) SetFiles(files []*models.File) {
m.Files = files
sort.SliceStable(m.Files, func(i, j int) bool {
return m.Files[i].Name < m.Files[j].Name
})
m.SetTree()
}

View File

@ -3,6 +3,7 @@ package gui
import (
"os"
"path/filepath"
"sort"
"strings"
"github.com/jesseduffield/lazygit/pkg/commands/models"
@ -62,5 +63,11 @@ func GetFlatTreeFromStatusFiles(files []*models.File) *models.StatusLineNode {
root.Sort()
// Move merge conflicts to top. This is the one way in which sorting
// differs between flat mode and tree mode
sort.SliceStable(root.Children, func(i, j int) bool {
return root.Children[i].File != nil && root.Children[i].File.HasMergeConflicts && !(root.Children[j].File != nil && root.Children[j].File.HasMergeConflicts)
})
return root
}