branch: externals/phps-mode commit 5f445cd0d66fb75e2d8e8aa21625e021d30ab70d Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Fixed indentation for while expressions --- phps-mode-functions.el | 10 ++++++---- phps-mode-test-functions.el | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/phps-mode-functions.el b/phps-mode-functions.el index b98aaa9..8e14b43 100644 --- a/phps-mode-functions.el +++ b/phps-mode-functions.el @@ -267,11 +267,13 @@ (when after-special-control-structure-first-on-line (setq first-token-is-nesting-increase t))) - (when phps-mode-functions-verbose - (message "\nStarted inline control-structure after %s at %s\n" after-special-control-structure-token token)) + ;; Don't start inline control structures after a while ($condition); expression + (when (not (string= token ";")) + (when phps-mode-functions-verbose + (message "\nStarted inline control-structure after %s at %s\n" after-special-control-structure-token token)) - (setq in-inline-control-structure t) - (setq temp-pre-indent (1+ column-level)))) + (setq in-inline-control-structure t) + (setq temp-pre-indent (1+ column-level))))) (setq after-special-control-structure nil) (setq after-special-control-structure-token nil) diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el index d284e7e..47da2bc 100644 --- a/phps-mode-test-functions.el +++ b/phps-mode-test-functions.el @@ -159,6 +159,11 @@ ;; (message "Tokens: %s" phps-mode-lexer-tokens) (should (equal '((1 (0 0)) (2 (1 0)) (3 (0 0))) (phps-mode-test-functions--hash-to-list (phps-mode-functions-get-lines-indent))))) + (phps-mode-test-with-buffer + "<?php\ndo {\n echo 'true';\n} while ($number > 0\n && $letter > 0\n);" + "Do while loop with multi-line condition" + (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0 0))) (phps-mode-test-functions--hash-to-list (phps-mode-functions-get-lines-indent))))) + ) (defun phps-mode-test-functions-get-lines-indent-multi-line-assignments ()