diff --git a/smartparens.el b/smartparens.el index db769c65..4c646cf3 100644 --- a/smartparens.el +++ b/smartparens.el @@ -7517,7 +7517,8 @@ Examples: (goto-char (,comment-bound (sp-get-comment-bounds))) (unless ,eob-test (,forward-fn 1))) (unless ,eob-test - (,forward-fn (max (length prefix) 1)))))))) + (,forward-fn (max (length prefix) 1)))) + (setq prefix nil))))) (defun sp-skip-forward-to-symbol (&optional stop-at-string stop-after-string stop-inside-string) "Skip whitespace and comments moving forward. diff --git a/test/smartparens-framework-test.el b/test/smartparens-framework-test.el index 395f5745..86d0ede3 100644 --- a/test/smartparens-framework-test.el +++ b/test/smartparens-framework-test.el @@ -32,6 +32,15 @@ delimiter." (insert "|") (should (equal (buffer-string) "foo|\n;; \"bar\"\nbaz")))) +(ert-deftest sp-test-sp-skip-backward-to-symbol-reset-prefix () + "If the first skip was a prefix skip, we need to reset the +prefix after jumping over it, otherwise each successive skip +would move (length prefix) characters" + (let ((sp-sexp-prefix '((emacs-lisp-mode regexp "\\(?:aaa\\)")))) + (sp-test-with-temp-elisp-buffer "foo bar aaa|(baz)" + (sp-skip-backward-to-symbol) + (sp-buffer-equals "foo bar| aaa(baz)")))) + (ert-deftest sp-test-looking-back () (sp-test-with-temp-elisp-buffer "foo \\|\\ bar" (should (sp--looking-back "\\\\+"))