From 48d71236152bab7952f99f8be3afad01d683db58 Mon Sep 17 00:00:00 2001 From: Mihai Cristian Tanase Date: Fri, 15 Dec 2023 11:22:52 +0200 Subject: [PATCH 1/2] Fix jumping to next/prev paren/brace from a string is not working Example of test: { fun(a, "T[]est", test()); } With cursor at [], the commands ]), [(, ]} or [{ don't do anything. --- evil-common.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/evil-common.el b/evil-common.el index 985fdb3e..c305c256 100644 --- a/evil-common.el +++ b/evil-common.el @@ -1360,11 +1360,11 @@ last successful match (that caused COUNT to reach zero)." (cond ((> dir 0) (while (progn - (up-list dir) + (up-list dir t) (/= (char-before) close)))) (t (while (progn - (up-list dir) + (up-list dir t) (/= (char-after) open))))) (error (goto-char pnt))))))) (cond From bcf692cecf508e1f12897abf2e91ca0a26f4e952 Mon Sep 17 00:00:00 2001 From: Mihai Cristian Tanase Date: Fri, 15 Dec 2023 20:58:38 +0200 Subject: [PATCH 2/2] Add tests to verify next/prev paren jumping from inside a string --- evil-tests.el | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/evil-tests.el b/evil-tests.el index cd032dfc..e7bf0809 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -5874,6 +5874,89 @@ This buffer is for notes." ("2])") "foo ( { ( bar ) baz } [)]"))) +(ert-deftest evil-test-paren-jump-from-string () + "Test jump to next/prev paren from a string" + :tags '(evil motion) + (evil-test-buffer + "{ + fun(a, \"T[]est\", test()); +} +" + ("[(") + "{ + fun[(]a, \"Test\", test()); +} +" + ("])") + "{ + fun(a, \"Test\", test()[)]; +} +") + (evil-test-buffer + "{ + fun(a, \"T[]est\", test()); +} +" + ("])") + "{ + fun(a, \"Test\", test()[)]; +} +" + ("[(") + "{ + fun[(]a, \"Test\", test()); +} +") + (evil-test-buffer + "{ + fun(a, \"T[]est\", test()); +} +" + ("[{") + "[{] + fun(a, \"Test\", test()); +} +") + (evil-test-buffer + "{ + fun(a, \"T[]est\", test()); +} +" + ("]}") + "{ + fun(a, \"Test\", test()); +[}] +")) + +(ert-deftest evil-test-paren-jump-inside-string-from-string () + "Test jump to next/prev paren inside string from a string" + :tags '(evil motion) + (evil-test-buffer + "{ (\"Test with paren (inside multi (l[e]vel))\", test()); } " + ("[(") + "{ (\"Test with paren (inside multi [(]level))\", test()); } " + ("[(") + "{ (\"Test with paren [(]inside multi (level))\", test()); } ") + (evil-test-buffer + "{ (\"Test with paren (inside multi (l[e]vel))\", test()); } " + ("])") + "{ (\"Test with paren (inside multi (level[)])\", test()); } " + ("])") + "{ (\"Test with paren (inside multi (level)[)]\", test()); } ") + (evil-test-buffer + "{ (\"Test with paren {inside multi {l[e]vel}}\", test()); } " + ("[{") + "{ (\"Test with paren {inside multi [{]level}}\", test()); } " + ("[{") + "{ (\"Test with paren [{]inside multi {level}}\", test()); } ") + (evil-test-buffer + "{ (\"Test with paren {inside multi {l[e]vel}}\", test()); } " + ("]}") + "{ (\"Test with paren {inside multi {level[}]}\", test()); } " + ("]}") + "{ (\"Test with paren {inside multi {level}[}]\", test()); } ")) + + (ert-deftest evil-test-next-mark () "Test `evil-next-mark', `evil-previous-mark'" :tags '(evil motion)