mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-29 22:48:24 +02:00
Remove utils.Clamp, use lo.Clamp instead
This commit is contained in:
@@ -52,7 +52,7 @@ func (self *ListRenderer) ModelIndexToViewIndex(modelIndex int) int {
|
||||
}
|
||||
|
||||
func (self *ListRenderer) ViewIndexToModelIndex(viewIndex int) int {
|
||||
viewIndex = utils.Clamp(viewIndex, 0, self.list.Len()+self.numNonModelItems)
|
||||
viewIndex = lo.Clamp(viewIndex, 0, self.list.Len()+self.numNonModelItems)
|
||||
if self.modelIndicesByViewIndex != nil {
|
||||
return self.modelIndicesByViewIndex[viewIndex]
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package traits
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type RangeSelectMode int
|
||||
@@ -85,7 +86,7 @@ func (self *ListCursor) clampValue(value int) int {
|
||||
clampedValue := -1
|
||||
length := self.getLength()
|
||||
if length > 0 {
|
||||
clampedValue = utils.Clamp(value, 0, length-1)
|
||||
clampedValue = lo.Clamp(value, 0, length-1)
|
||||
}
|
||||
|
||||
return clampedValue
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
// State represents the selection state of the merge conflict context.
|
||||
@@ -37,14 +38,14 @@ func (s *State) setConflictIndex(index int) {
|
||||
if len(s.conflicts) == 0 {
|
||||
s.conflictIndex = 0
|
||||
} else {
|
||||
s.conflictIndex = utils.Clamp(index, 0, len(s.conflicts)-1)
|
||||
s.conflictIndex = lo.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 = utils.Clamp(index, 0, len(selections)-1)
|
||||
s.selectionIndex = lo.Clamp(index, 0, len(selections)-1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user