Skip to content

Commit

Permalink
fix: reset prefix after skipping over it in sp-skip-to-symbol-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuco1 committed Oct 7, 2020
1 parent 927f2b0 commit d1a433a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion smartparens.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions test/smartparens-framework-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 "\\\\+"))
Expand Down

0 comments on commit d1a433a

Please sign in to comment.