Skip to content

Commit

Permalink
Merge pull request #801 from emacs-php/fix/issue-793
Browse files Browse the repository at this point in the history
Fix array alignment issue when an empty line is present
  • Loading branch information
zonuexe authored Jan 9, 2025
2 parents b45992a + 0a33fc0 commit 0f756a8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
7 changes: 4 additions & 3 deletions lisp/php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,7 @@ but only if the setting is enabled."
((assq 'defun-block-intro c-syntactic-context) nil)
((assq 'defun-close c-syntactic-context) nil)
((assq 'statement-cont c-syntactic-context) nil)
(t
(save-excursion
((save-excursion
(beginning-of-line)
(let ((beginning-of-langelem (cdr langelem))
(beginning-of-current-line (point))
Expand All @@ -651,8 +650,10 @@ but only if the setting is enabled."
(skip-chars-backward " \r\n")
(backward-char 1))
(and (not (eq (point) beginning-of-current-line))
(not (php-in-string-or-comment-p))
(not (looking-at-p ","))
(not (php-in-string-or-comment-p))))
(save-excursion
(backward-char) (not (looking-at-p ",")))))
'+)
(t nil)))))))

Expand Down
9 changes: 9 additions & 0 deletions tests/indent/issue-793.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [
'foo' => 1, // ###php-mode-test### ((indent 4))
'bar' => 2,

'buz' => 3, // ###php-mode-test### ((indent 4))
'buzbuz' => 4, // ###php-mode-test### ((indent 4))
];
14 changes: 7 additions & 7 deletions tests/php-mode-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -644,14 +644,14 @@ Meant for `php-mode-test-issue-503'."
(goto-char (point-min))
(should (eq (php-mode-test-in-function-p nil) nil))))

(ert-deftest php-mode-test-issue-623 ()
"Proper alignment object -> accessor."
(with-php-mode-test ("indent/issue-623.php" :indent t :magic t)))

(ert-deftest php-mode-test-issue-702 ()
"Proper alignment arglist."
(ert-deftest php-mode-test-indentation-issues ()
;; Proper alignment object -> accessor.
(with-php-mode-test ("indent/issue-623.php" :indent t :magic t))
;; Proper alignment arglist.
(with-php-mode-test ("indent/issue-702.php" :indent t :magic t))
(with-php-mode-test ("indent/issue-726.php" :indent t :magic t)))
(with-php-mode-test ("indent/issue-726.php" :indent t :magic t))
;; Proper alignment arglist that contains empty lines.
(with-php-mode-test ("indent/issue-793.php" :indent t :magic t)))

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

0 comments on commit 0f756a8

Please sign in to comment.