branch: externals/phps-mode commit 371893128041ea5b44f2c85b1b882f8f42bb7a94 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Basic tests for indentation calculation passes --- phps-mode-functions.el | 15 +++++++++------ phps-mode-test-functions.el | 1 - 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/phps-mode-functions.el b/phps-mode-functions.el index 4d701c0..b0bd25c 100644 --- a/phps-mode-functions.el +++ b/phps-mode-functions.el @@ -103,7 +103,7 @@ ;; Decrement column (if allow-custom-column-decrement (progn - (setq column-level (- nesting-end nesting-start)) + (setq column-level (- column-level (- nesting-start nesting-end))) (setq allow-custom-column-increment nil)) (setq column-level (1- column-level)))) @@ -143,7 +143,7 @@ ;; Increase indentation (if allow-custom-column-increment (progn - (setq column-level (- nesting-end nesting-start)) + (setq column-level (+ column-level (- nesting-end nesting-start))) (setq allow-custom-column-increment nil)) (setq column-level (1+ column-level)))) @@ -191,6 +191,8 @@ (when (and switch-curly-stack (= curly-bracket-level (car switch-curly-stack))) (setq curly-bracket-level (1- curly-bracket-level)) + ;; (message "Found ending switch curly bracket") + (setq allow-custom-column-decrement t) (pop switch-curly-stack)) (when first-token-on-line @@ -206,6 +208,7 @@ ;; (message "Found ending alternative token %s %s" token alternative-control-structure-level) (when (equal token 'T_ENDSWITCH) + (setq allow-custom-column-decrement t) (setq alternative-control-structure-level (1- alternative-control-structure-level))) (when first-token-on-line @@ -220,10 +223,10 @@ (if (string= token "{") (when (equal after-special-control-structure-token 'T_SWITCH) - (setq curly-bracket-level (1+ curly-bracket-level)) - (setq allow-custom-column-increment t) ;; (message "Opening switch, increase curly brackets to %s" curly-bracket-level) - (push curly-bracket-level switch-curly-stack)) + (push curly-bracket-level switch-curly-stack) + (setq allow-custom-column-increment t) + (setq curly-bracket-level (1+ curly-bracket-level))) ;; Is it the start of an alternative control structure? (if (string= token ":") @@ -322,7 +325,7 @@ ;; Decrement column (if allow-custom-column-decrement (progn - (setq column-level (- nesting-end nesting-start)) + (setq column-level (- column-level (- nesting-start nesting-end))) (setq allow-custom-column-increment nil)) (setq column-level (1- column-level)))) diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el index af254d9..3a2330a 100644 --- a/phps-mode-test-functions.el +++ b/phps-mode-test-functions.el @@ -81,7 +81,6 @@ (phps-mode-test-with-buffer "<?php\nswitch ($condition) {\n case true:\n echo 'here';\n echo 'here 2';\n case false:\n echo 'here 4';\n default:\n echo 'here 3';\n}\n" "Switch, case, default" - (message "tokens %s" phps-mode-lexer-tokens) (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (2 0)) (6 (1 0)) (7 (2 0)) (8 (1 0)) (9 (2 0)) (10 (0 0))) (phps-mode-test-functions--hash-to-list (phps-mode-functions-get-lines-indent))))) ;; TODO NOWDOC, HEREDOC