summaryrefslogtreecommitdiffstats
path: root/pkg/gui/mergeconflicts/state.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-01-30 14:46:46 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commitc084abb378bc4ae2902e52f399c0f53968d1e717 (patch)
tree4f91ae022ae9a0c47042976c3c73f09a47925837 /pkg/gui/mergeconflicts/state.go
parent8ea7b7a62e5a09314bbe7a446a45e649d66b524d (diff)
move more view model logic into the files view model
Diffstat (limited to 'pkg/gui/mergeconflicts/state.go')
-rw-r--r--pkg/gui/mergeconflicts/state.go13
1 files changed, 2 insertions, 11 deletions
diff --git a/pkg/gui/mergeconflicts/state.go b/pkg/gui/mergeconflicts/state.go
index d84f05545..b40b979e9 100644
--- a/pkg/gui/mergeconflicts/state.go
+++ b/pkg/gui/mergeconflicts/state.go
@@ -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
-}