From 48cdd8df098a90816b4029d75c6ad0dae967b318 Mon Sep 17 00:00:00 2001 From: Tom Dalziel Date: Wed, 10 Jul 2024 18:37:29 +0200 Subject: [PATCH] gi works in visual line state --- evil-commands.el | 5 ++++- evil-tests.el | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/evil-commands.el b/evil-commands.el index 3a0b3b35..45a6e67a 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -2734,11 +2734,14 @@ the lines." (evil-insert count vcount skip-empty-lines) (add-hook 'post-command-hook #'evil-maybe-remove-spaces))) -(defun evil-insert-resume (count) +(evil-define-command evil-insert-resume (count) "Switch to Insert state at previous insertion point. The insertion will be repeated COUNT times. If called from visual state, only place point at the previous insertion position but do not switch to insert state." + :keep-visual t + :type exclusive + :jump t (interactive "p") (evil-goto-mark ?^ t) (unless (evil-visual-state-p) diff --git a/evil-tests.el b/evil-tests.el index fb06d762..7ccef732 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -6075,6 +6075,27 @@ This buffer is for notes." ("]}") "{ (\"Test with paren {inside multi {level}[}]\", test()); } ")) +(ert-deftest evil-test-insert-resume () + "Test `evil-insert-resume'" + :tags '(evil motion) + (ert-info ("Can move to last insert location and take a count") + (evil-test-buffer + "alpha bravo [ ]delta echo" + ("i" "charlie" [escape] "^") + "[a]lpha bravo charlie delta echo" + ("2gi" " zulu" [escape]) + "alpha bravo charlie zulu zul[u] delta echo")) + (ert-info ("Can move to `^' marker in visual line state") + (evil-test-buffer + "alpha [b]ravo\ncharlie delta\necho foxtrot" + ("i" [escape] "/foxtrot" [return]) + "alpha bravo\ncharlie delta\necho [f]oxtrot" + ("Vk") + "alpha bravo\ncharl[i]e delta\necho foxtrot" + ("gi") + "alpha [b]ravo\ncharlie delta\necho foxtrot" + ("vd") + "alpha [o]xtrot"))) (ert-deftest evil-test-next-mark () "Test `evil-next-mark', `evil-previous-mark'"