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: ")]
|
return [Argument("lineno", type=type(0), prompt="Goto line: ")]
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
n = vargs["lineno"]
|
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:
|
if n < 0:
|
||||||
n = len(w.buffer.lines) - n
|
n = len(w.buffer.lines) + n + 1
|
||||||
# now let's protect the user from their own mistakes
|
if n > len(w.buffer.lines):
|
||||||
if n < 0:
|
n = len(w.buffer.lines)
|
||||||
n = 0
|
elif n < 1:
|
||||||
elif n >= len(w.buffer.lines):
|
n = 1
|
||||||
n = len(w.buffer.lines) - 1
|
|
||||||
else:
|
|
||||||
n -= 1
|
|
||||||
# ok so go to the line now
|
|
||||||
w.goto_line(n)
|
w.goto_line(n)
|
||||||
class ForwardLines(Method):
|
class ForwardLines(Method):
|
||||||
'''Move forward the specified number of characters'''
|
'''Move forward the specified number of characters'''
|
||||||
|
|
Loading…
Reference in New Issue