Skip to content

Commit eb880d8

Browse files
committed
simplify code
1 parent 1ead9ce commit eb880d8

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

internal/display/softwrap.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,7 @@ func (w *BufWindow) diff(s1, s2 SLoc) int {
291291
// within the buffer boundaries.
292292
func (w *BufWindow) Scroll(s SLoc, n int) SLoc {
293293
if !w.Buf.Settings["softwrap"].(bool) {
294-
s.Line += n
295-
if s.Line < 0 {
296-
s.Line = 0
297-
}
298-
if s.Line > w.Buf.LinesNum()-1 {
299-
s.Line = w.Buf.LinesNum() - 1
300-
}
294+
s.Line = util.Clamp(s.Line + n, 0, w.Buf.LinesNum()-1)
301295
return s
302296
}
303297
return w.scroll(s, n)

0 commit comments

Comments
 (0)