1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

move more view model logic into the files view model

This commit is contained in:
Jesse Duffield
2022-01-30 14:46:46 +11:00
parent 8ea7b7a62e
commit c084abb378
17 changed files with 392 additions and 323 deletions

View File

@ -39,14 +39,14 @@ func (s *State) setConflictIndex(index int) {
if len(s.conflicts) == 0 {
s.conflictIndex = 0
} else {
s.conflictIndex = clamp(index, 0, len(s.conflicts)-1)
s.conflictIndex = utils.Clamp(index, 0, len(s.conflicts)-1)
}
s.setSelectionIndex(s.selectionIndex)
}
func (s *State) setSelectionIndex(index int) {
if selections := s.availableSelections(); len(selections) != 0 {
s.selectionIndex = clamp(index, 0, len(selections)-1)
s.selectionIndex = utils.Clamp(index, 0, len(selections)-1)
}
}
@ -183,12 +183,3 @@ func (s *State) ContentAfterConflictResolve(selection Selection) (bool, string,
return true, content, nil
}
func clamp(x int, min int, max int) int {
if x < min {
return min
} else if x > max {
return max
}
return x
}