Skip to content

Commit

Permalink
[Fix Fuco1#634] symbol-skipping should not stop at delimiter at the e…
Browse files Browse the repository at this point in the history
…nd of comment
  • Loading branch information
Fuco1 authored and jojojames committed Mar 31, 2017
1 parent 122c2ce commit 73532f7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
6 changes: 4 additions & 2 deletions smartparens.el
Original file line number Diff line number Diff line change
Expand Up @@ -6602,8 +6602,10 @@ Examples:
(and stop-inside-string
(sp-point-in-string)
(not (sp-point-in-string (,inc (point)))))
(,looking allowed-pairs)
(,looking allowed-strings)))
(and (,looking allowed-pairs)
(or in-comment (not (sp-point-in-comment))))
(and (,looking allowed-strings)
(or in-comment (not (sp-point-in-comment))))))
(or (member (char-syntax (,next-char-fn)) '(?< ?> ?! ?| ?\ ?\\ ?\" ?' ?.))
(unless in-comment (sp-point-in-comment))))
(when (and (not in-comment)
Expand Down
7 changes: 6 additions & 1 deletion test/smartparens-commands-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,12 @@ be."
"(f|oo)\nbar ;; baz (foo) baz\n(quux)")

("(foo)\nbar ;; baz (f|oo baz)\n(quux)"
"(foo)\nbar ;; baz (f|oo) baz\n(quux)"))
"(foo)\nbar ;; baz (f|oo) baz\n(quux)")

;; #634
("(let ((a 4)\n ;; (fail)\n |(+ 1)\n ))\n"
"(let ((a 4))\n ;; (fail)\n| (+ 1)\n )\n"
"(let ((a 4)))\n;; (fail)\n|(+ 1)\n\n"))

(((mode 'racket)
(sp-sexp-prefix '((racket-mode regexp "#?['`,]@?"))))
Expand Down
16 changes: 16 additions & 0 deletions test/smartparens-framework-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,19 @@
(should (sp-point-in-symbol)))
(sp-test-with-temp-elisp-buffer "foo-b|ar"
(should (sp-point-in-symbol))))

;; #634
(ert-deftest sp-test-sp-skip-backward-to-symbol-sexp-at-the-end-of-comment ()
"When we are skipping backward and land on a sexp delimiter
right at the end of comment, and we started outside a comment, we
should skip the current comment instead of ending on the
delimiter."
(sp-test-with-temp-elisp-buffer "foo\n;; (bar)\n|baz"
(sp-skip-backward-to-symbol)
(insert "|")
(should (equal (buffer-string) "foo|\n;; (bar)\nbaz")))

(sp-test-with-temp-elisp-buffer "foo\n;; \"bar\"\n|baz"
(sp-skip-backward-to-symbol)
(insert "|")
(should (equal (buffer-string) "foo|\n;; \"bar\"\nbaz"))))

0 comments on commit 73532f7

Please sign in to comment.