branch: externals/phps-mode commit af263a54623db63570470a565281ce4f15a20dd4 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Improved indentation detection of start of alternative control structure --- phps-mode-indent.el | 5 +++-- test/phps-mode-test-indent.el | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/phps-mode-indent.el b/phps-mode-indent.el index 7862f73b54..7658c79ad2 100644 --- a/phps-mode-indent.el +++ b/phps-mode-indent.el @@ -351,7 +351,7 @@ ;; Alternative control structures are always ;; indication of start of command ((string-match-p - "\\:[\t ]*$" + ")[\ t]*:[\t ]*$" match) (setq not-found @@ -1104,7 +1104,8 @@ ((reference-line (phps-mode-indent--get-previous-reference-command-line))) - ;; (message "reference-line: %S" reference-line) + (phps-mode-debug-message + (message "reference-line: %S" reference-line)) (let ((reference-indentation (phps-mode-indent--string-indentation reference-line))) diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el index 064e2bf986..2e88a17f7b 100644 --- a/test/phps-mode-test-indent.el +++ b/test/phps-mode-test-indent.el @@ -157,6 +157,14 @@ (phps-mode-indent--get-previous-reference-command-line) "require_once(CONSTANT . 'path');"))) + (with-temp-buffer + (insert "<?php\n $variable =\n Object::\n method($variable2, true);\n // Line comment") + (goto-char (point-max)) + (should + (string= + (phps-mode-indent--get-previous-reference-command-line) + " $variable ="))) + (with-temp-buffer (insert "<?php\nif (true) {\n array(\n 8,\n );") (goto-char (point-max)) @@ -571,14 +579,8 @@ "<?php\n\n$array = [\n 'pointers' => (!empty($data['point1'])\n && $data['point2'] === 22)\n || (!empty($data['point3'])\n && $data['point4'] === 33)\n || (!empty($data['point4'])\n && $data['point4'] === 44),\n 'arrows' =>\n $data['arrows'],\n];\n" "Another multi-line logical expression inside associative array") - ;; TODO Make this pass - (phps-mode-test-indent--should-equal - "<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"UTF-8\">\n <title>Was here</title>\n <meta charset=\"ISO-8559-1\" />\n</head>\n<body>\n <div>\n <p>\n My mixed content\n <br>\n Was here\n </p>\n </div>\n</body>\n</html>" - "Plain HTML markup") - - ;; TODO Make this pass (phps-mode-test-indent--should-equal - "<?php\nif (true) {\n $variable =\n Object::\n method($variable2, true);\n // Line comment\n $variable['index'] = $variabl2->method2();\n}" + "<?php\nif (true) {\n $variable =\n Object::\n method($variable2, true);\n // Line comment\n $variable['index'] = $variabl2->method2();\n}" "Mix of various types of statements and expressions") ;; TODO Make this pass @@ -595,6 +597,12 @@ "<?php\nif (true) {\n echo '<script type=\"text/javascript\">'\n . 'jQuery(document).ready(function() { '\n . 'window.open(\"'\n . $url . '\", \"_blank\");'\n . ' });</script>';\n}\n" "Multi-line echo statement with HTML markup 3") + ;; TODO Make this pass + (phps-mode-test-indent--should-equal + "<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"UTF-8\">\n <title>Was here</title>\n <meta charset=\"ISO-8559-1\" />\n</head>\n<body>\n <div>\n <p>\n My mixed content\n <br>\n Was here\n </p>\n </div>\n</body>\n</html>" + "Plain HTML markup") + + ) (defun phps-mode-test-indent--get-lines-indent-psr-2 ()