branch: externals/phps-mode commit 53915512870b2bec9911374063dac196476c07a5 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Added a new indent test and made it pass --- phps-mode-indent.el | 15 +++++++++++---- test/phps-mode-test-indent.el | 4 ++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/phps-mode-indent.el b/phps-mode-indent.el index 77cebafdd0..9dc1690461 100644 --- a/phps-mode-indent.el +++ b/phps-mode-indent.el @@ -825,7 +825,7 @@ ;; If it's on the same line we ignore it (forward-line (* -1 move-length1)) (end-of-line) - (forward-char -1) + (search-backward-regexp ";" nil t) ;; Skip the semi-colon (let ((not-found t) (is-assignment nil) @@ -922,7 +922,7 @@ ;; If it started on the same line we ignore it (forward-line (* -1 move-length1)) (end-of-line) - (forward-char -1) + (search-backward-regexp "," nil t) ;; Skip the colon ;; (message ;; "at-line-start: %S" @@ -1101,7 +1101,7 @@ ;; If it's on the same line we ignore it (forward-line (* -1 move-length1)) (end-of-line) - (forward-char -1) + (search-backward-regexp ";" nil t) ;; Skip the semi-colon (let ((not-found t) (is-assignment nil) @@ -1234,7 +1234,13 @@ ;; define('_PRIVATE_ROOT', ;; 'here'); ;; echo 'here'; - (when is-function-call + ;; but ignore + ;; if (true) { + ;; define('_PRIVATE_ROOT', 'here'); + ;; echo 'here'; + (when (and + is-function-call + (not is-same-line-p)) (setq new-indentation (- new-indentation tab-width))) @@ -1417,6 +1423,7 @@ ((and current-line-starts-with-closing-bracket (not previous-line-ends-with-opening-bracket)) + ;; Backtrack to line were bracket started ;; and use indentation from that line for this line (forward-line (* -1 move-length1)) diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el index cbdbea942e..8f7d27516d 100644 --- a/test/phps-mode-test-indent.el +++ b/test/phps-mode-test-indent.el @@ -324,6 +324,10 @@ "<?php\nself::addAutoLoadPaths(array(\n _SYSTEM_ROOT_,\n _PRIVATE_ROOT_,\n _PUBLIC_ROOT_,\n _SITE_ROOT_\n));\n" "Multiline function call with multiline array as argument") + (phps-mode-test-indent--should-equal + "<?php\nif (true) {\n $random = self::getData();\n // My random comment\n}\n" + "Comment after assignment from method call on same line") + ) (defun phps-mode-test-indent--get-lines-indent-psr-2 ()