aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Cristian Tanase <mihaicristian.tanase@gmail.com>2023-12-15 21:06:32 +0200
committerGitHub <noreply@github.com>2023-12-15 20:06:32 +0100
commiteced3088ce860431b6d0e0af2409c56d754ffab2 (patch)
tree9fb24f0b3476dc83cc98b9c7a7ee5449ae406a37
parent16506d934342fd905ce4c88684f04ddb123c02a4 (diff)
Fix jumping to next/prev paren/brace from a string is not working (#1849)
-rw-r--r--evil-common.el4
-rw-r--r--evil-tests.el83
2 files changed, 85 insertions, 2 deletions
diff --git a/evil-common.el b/evil-common.el
index 985fdb3..c305c25 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
diff --git a/evil-tests.el b/evil-tests.el
index cd032df..e7bf080 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)