parent
e6db05be3b
commit
2f4b124477
18
method.py
18
method.py
|
@ -123,20 +123,12 @@ class GotoLine(Method):
|
|||
return [Argument("lineno", type=type(0), prompt="Goto line: ")]
|
||||
def _execute(self, w, **vargs):
|
||||
n = vargs["lineno"]
|
||||
# 0 is not a supported input line number
|
||||
if n == 0:
|
||||
return
|
||||
# negative line numbers are offsets from the end
|
||||
if n < 0:
|
||||
n = len(w.buffer.lines) - n
|
||||
# now let's protect the user from their own mistakes
|
||||
if n < 0:
|
||||
n = 0
|
||||
elif n >= len(w.buffer.lines):
|
||||
n = len(w.buffer.lines) - 1
|
||||
else:
|
||||
n -= 1
|
||||
# ok so go to the line now
|
||||
n = len(w.buffer.lines) + n + 1
|
||||
if n > len(w.buffer.lines):
|
||||
n = len(w.buffer.lines)
|
||||
elif n < 1:
|
||||
n = 1
|
||||
w.goto_line(n)
|
||||
class ForwardLines(Method):
|
||||
'''Move forward the specified number of characters'''
|
||||
|
|
Loading…
Reference in New Issue