Skip to content

Commit

Permalink
Fix also 'G'.
Browse files Browse the repository at this point in the history
  • Loading branch information
fukamachi committed Aug 31, 2023
1 parent b7ccaad commit c69c366
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
15 changes: 9 additions & 6 deletions extensions/vi-mode/commands.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,15 @@
(define-motion vi-goto-line (&optional n) ("P")
(:type :line
:jump t)
(if (null n)
(progn
(move-to-end-of-buffer)
(line-start (current-point)))
(goto-line n))
(skip-whitespace-forward (current-point) t))
(let ((col (point-charpos (current-point))))
(if (null n)
(progn
(move-to-end-of-buffer)
(when (and (bolp (current-point))
(eolp (current-point)))
(line-offset (current-point) -1)))
(goto-line n))
(move-to-column (current-point) col)))

(define-command vi-return (&optional (n 1)) ("p")
(vi-next-line n)
Expand Down
8 changes: 6 additions & 2 deletions extensions/vi-mode/tests/motion.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,17 @@
(cmd "$")
(ok (buf= #?"abcdefg[h]\nijklmn\n")))))

(deftest vi-goto-first-line
(deftest vi-goto-line
(with-fake-interface ()
(with-vi-buffer (#?"abc\ndef\nghi\nj[k]l\n")
(cmd "gg")
(ok (buf= #?"a[b]c\ndef\nghi\njkl\n"))
(cmd "3gg")
(ok (buf= #?"abc\ndef\ng[h]i\njkl\n")))))
(ok (buf= #?"abc\ndef\ng[h]i\njkl\n"))
(cmd "G")
(ok (buf= #?"abc\ndef\nghi\nj[k]l\n"))
(cmd "2G")
(ok (buf= #?"abc\nd[e]f\nghi\njkl\n")))))

(deftest vi-find-char
(with-fake-interface ()
Expand Down

0 comments on commit c69c366

Please sign in to comment.