mirror of
https://github.com/zyedidia/micro.git
synced 2026-04-01 07:37:24 +09:00
Rewrite Loc.MoveLA(n): do not call util.Abs(n) in cycle, cleaner code
This commit is contained in:
@@ -113,14 +113,13 @@ func (l Loc) left(buf *LineArray) Loc {
|
||||
// MoveLA moves the cursor n characters to the left or right
|
||||
// It moves the cursor left if n is negative
|
||||
func (l Loc) MoveLA(n int, buf *LineArray) Loc {
|
||||
if n > 0 {
|
||||
for i := 0; i < n; i++ {
|
||||
l = l.right(buf)
|
||||
}
|
||||
return l
|
||||
for n > 0 {
|
||||
l = l.right(buf)
|
||||
n--
|
||||
}
|
||||
for i := 0; i < util.Abs(n); i++ {
|
||||
for n < 0 {
|
||||
l = l.left(buf)
|
||||
n++
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user