Fix perl-mode indentation after a hanging paren
* lisp/progmodes/perl-mode.el (perl-hanging-paren-p): Allow comments. (Bug#34245) * test/lisp/progmodes/perl-mode-tests.el (perl-test-bug-34245): New test.
This commit is contained in:
parent
dd2053e8cd
commit
2a8f458719
2 changed files with 18 additions and 1 deletions
|
@ -968,7 +968,7 @@ changed by, or (parse-state) if line starts in a quoted string."
|
|||
|
||||
(defun perl-hanging-paren-p ()
|
||||
"Non-nil if we are right after a hanging parenthesis-like char."
|
||||
(and (looking-at "[ \t]*$")
|
||||
(and (looking-at "[ \t]*\\(?:#.*\\)?$")
|
||||
(save-excursion
|
||||
(skip-syntax-backward " (") (not (bolp)))))
|
||||
|
||||
|
|
|
@ -28,6 +28,23 @@
|
|||
(font-lock-ensure (point-min) (point-max))
|
||||
(should (equal (get-text-property 4 'face) 'font-lock-variable-name-face))))
|
||||
|
||||
(ert-deftest perl-test-bug-34245 ()
|
||||
"Test correct indentation after a hanging paren, with and without comments."
|
||||
(with-temp-buffer
|
||||
(perl-mode)
|
||||
(insert "my @foo = (\n\"bar\",\n\"baz\",\n);")
|
||||
(insert "\n\n")
|
||||
(insert "my @ofoo = (\t\t# A comment.\n\"obar\",\n\"obaz\",\n);")
|
||||
(indent-region (point-min) (point-max))
|
||||
(goto-char (point-min))
|
||||
(forward-line)
|
||||
(skip-chars-forward " \t")
|
||||
(should (equal (current-column) perl-indent-level))
|
||||
(search-forward "# A comment.")
|
||||
(forward-line)
|
||||
(skip-chars-forward " \t")
|
||||
(should (equal (current-column) perl-indent-level))))
|
||||
|
||||
;;;; Re-use cperl-mode tests
|
||||
|
||||
(defvar cperl-test-mode)
|
||||
|
|
Loading…
Add table
Reference in a new issue