File tree 1 file changed +6
-7
lines changed
1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 7
7
"github.com/jesseduffield/gocui"
8
8
"github.com/jesseduffield/lazygit/pkg/commands/patch"
9
9
"github.com/jesseduffield/lazygit/pkg/utils"
10
+ "github.com/samber/lo"
10
11
)
11
12
12
13
// State represents the current state of the patch explorer context i.e. when
@@ -177,15 +178,13 @@ func (s *State) SelectLine(newSelectedLineIdx int) {
177
178
s .selectLineWithoutRangeCheck (newSelectedLineIdx )
178
179
}
179
180
181
+ func (s * State ) clampLineIdx (lineIdx int ) int {
182
+ return lo .Clamp (lineIdx , 0 , len (s .patchLineIndices )- 1 )
183
+ }
184
+
180
185
// This just moves the cursor without caring about range select
181
186
func (s * State ) selectLineWithoutRangeCheck (newSelectedLineIdx int ) {
182
- if newSelectedLineIdx < 0 {
183
- newSelectedLineIdx = 0
184
- } else if newSelectedLineIdx > len (s .patchLineIndices )- 1 {
185
- newSelectedLineIdx = len (s .patchLineIndices ) - 1
186
- }
187
-
188
- s .selectedLineIdx = newSelectedLineIdx
187
+ s .selectedLineIdx = s .clampLineIdx (newSelectedLineIdx )
189
188
}
190
189
191
190
func (s * State ) SelectNewLineForRange (newSelectedLineIdx int ) {
You can’t perform that action at this time.
0 commit comments