Skip to content

Commit

Permalink
Fix comment bounds detection at bobp
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuco1 committed Jul 4, 2017
1 parent f5ffbc7 commit cb8d03a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion smartparens.el
Original file line number Diff line number Diff line change
Expand Up @@ -4168,7 +4168,8 @@ If the point is not inside a quoted string, return nil."
(end-of-line))
t))))
;; this means we got here by `sp-point-in-comment' condition
(forward-char)
(unless (and (bobp) (sp-point-in-comment))
(forward-char))
(point)))
(close (save-excursion
(while (and (not (eobp))
Expand Down
11 changes: 11 additions & 0 deletions test/smartparens-get-comment-bounds-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
(bar)"
(should (equal (sp-get-comment-bounds) '(11 . 40)))))

(ert-deftest sp-test-get-comment-bounds-elisp-with-comment-starting-at-bobp ()
(sp-test-with-temp-elisp-buffer ";; |foobar"
(should (equal (sp-get-comment-bounds) '(1 . 10)))))

(ert-deftest sp-test-get-comment-bounds-pascal ()
(sp-test-with-temp-buffer
"var foo:integer; (* foo|bar *)"
Expand All @@ -56,3 +60,10 @@
(pascal-mode)
(save-excursion (syntax-ppss 1)))
(should (equal (sp-get-comment-bounds) '(18 . 28)))))

(ert-deftest sp-test-get-comment-bounds-pascal-with-comment-starting-at-bobp ()
(sp-test-with-temp-buffer "(* foo|bar *)"
(progn
(pascal-mode)
(save-excursion (syntax-ppss 1)))
(should (equal (sp-get-comment-bounds) '(1 . 13)))))

0 comments on commit cb8d03a

Please sign in to comment.