puni-backward-sexp handles indented comment blocks incorrectly
djr7C4 opened this issue · 0 comments
When comment blocks are not indented puni-backward-sexp
works correctly and skips back to the start of the comment block. However, when they are indented it only skips past the last line in the comment block. To reproduce, paste the following into the scratch buffer:
(defun test-fun ()
;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with C-x C-f and enter text in its buffer.
|'test)
After M-x puni-backward-sexp
, the result is
(defun test-fun ()
;; This buffer is for text that is not saved, and for Lisp evaluation.
|;; To create a file, visit it with C-x C-f and enter text in its buffer.
'test)
while the expected result based on the docstring of puni-backward-sexp
is
(defun test-fun ()
|;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with C-x C-f and enter text in its buffer.
'test)
The problem is caused by a bug in puni--backward-consecutive-single-line-comments
which is called by puni-strict-backward-sexp
. Replacing
(save-excursion (forward-line -1)
(puni--begin-of-single-line-comment-p))
with
(save-excursion (forward-line -1)
(puni--forward-syntax " ")
(puni--begin-of-single-line-comment-p))
in the and
in the while loop seems to fix this issue.
puni-forward-sexp
does not have this problem and seems to handle indented comment blocks without issues.
This was tested with the latest version of puni (currently commit a39a4ec) with only a minimal configuration to install puni.