Skip to content

Commit 0a33fc0

Browse files
committed
Fix array alignment issue when an empty line is present
Fixed #793
1 parent b45992a commit 0a33fc0

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

Diff for: lisp/php-mode.el

+4-3
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,7 @@ but only if the setting is enabled."
627627
((assq 'defun-block-intro c-syntactic-context) nil)
628628
((assq 'defun-close c-syntactic-context) nil)
629629
((assq 'statement-cont c-syntactic-context) nil)
630-
(t
631-
(save-excursion
630+
((save-excursion
632631
(beginning-of-line)
633632
(let ((beginning-of-langelem (cdr langelem))
634633
(beginning-of-current-line (point))
@@ -651,8 +650,10 @@ but only if the setting is enabled."
651650
(skip-chars-backward " \r\n")
652651
(backward-char 1))
653652
(and (not (eq (point) beginning-of-current-line))
653+
(not (php-in-string-or-comment-p))
654654
(not (looking-at-p ","))
655-
(not (php-in-string-or-comment-p))))
655+
(save-excursion
656+
(backward-char) (not (looking-at-p ",")))))
656657
'+)
657658
(t nil)))))))
658659

Diff for: tests/indent/issue-793.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
return [
4+
'foo' => 1, // ###php-mode-test### ((indent 4))
5+
'bar' => 2,
6+
7+
'buz' => 3, // ###php-mode-test### ((indent 4))
8+
'buzbuz' => 4, // ###php-mode-test### ((indent 4))
9+
];

Diff for: tests/php-mode-test.el

+7-7
Original file line numberDiff line numberDiff line change
@@ -644,14 +644,14 @@ Meant for `php-mode-test-issue-503'."
644644
(goto-char (point-min))
645645
(should (eq (php-mode-test-in-function-p nil) nil))))
646646

647-
(ert-deftest php-mode-test-issue-623 ()
648-
"Proper alignment object -> accessor."
649-
(with-php-mode-test ("indent/issue-623.php" :indent t :magic t)))
650-
651-
(ert-deftest php-mode-test-issue-702 ()
652-
"Proper alignment arglist."
647+
(ert-deftest php-mode-test-indentation-issues ()
648+
;; Proper alignment object -> accessor.
649+
(with-php-mode-test ("indent/issue-623.php" :indent t :magic t))
650+
;; Proper alignment arglist.
653651
(with-php-mode-test ("indent/issue-702.php" :indent t :magic t))
654-
(with-php-mode-test ("indent/issue-726.php" :indent t :magic t)))
652+
(with-php-mode-test ("indent/issue-726.php" :indent t :magic t))
653+
;; Proper alignment arglist that contains empty lines.
654+
(with-php-mode-test ("indent/issue-793.php" :indent t :magic t)))
655655

656656
(ert-deftest php-mode-test-php74 ()
657657
"Test highlighting language constructs added in PHP 7.4."

0 commit comments

Comments
 (0)