branch: externals/phps-mode
commit dece7f242e6a6aafbba50a43739f8d8db19a1fe7
Author: Christian Johansson <[email protected]>
Commit: Christian Johansson <[email protected]>
Added more failing indentation tests
---
phps-mode-indent.el | 17 +++++++++++++++--
test/phps-mode-test-indent.el | 4 ++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index b3d4c378b1..36ba5ee371 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -249,6 +249,7 @@
;; (message "current-line-starts-with-closing-bracket: %S"
current-line-starts-with-closing-bracket)
;; (message "current-line-starts-with-opening-bracket: %S"
current-line-starts-with-opening-bracket)
+ ;; (message "previous-line-ends-with-closing-bracket: %S"
previous-line-ends-with-closing-bracket)
;; (message "previous-line-ends-with-opening-bracket: %S"
previous-line-ends-with-opening-bracket)
;; (message "previous-line-ends-with-terminus: %S"
previous-line-ends-with-terminus)
;; (message "previous-bracket-level: %S" previous-bracket-level)
@@ -259,6 +260,17 @@
(cond
+ ;; // die(
+ ;; echo 'here';
+ ((string-match-p
+ "^[\t ]*//"
+ previous-line-string)
+ (when current-line-starts-with-closing-bracket
+ (setq
+ new-indentation
+ (- new-indentation tab-width))
+ ))
+
;; class MyClass implements
;; myInterface
;; or
@@ -967,10 +979,11 @@
(and
not-found-command-start
(search-backward-regexp
- "\\(;\\|}\\|{\\|[\t ]*[^\t ]+[\t ]*$\\)"
+ "\\(;\\|}\\|{\\|^[\t ]*[^\t\n ]+[\t ]*$\\)"
nil
t))
- (let ((match (match-string-no-properties 0)))
+ (let ((match (match-string-no-properties 1)))
+ ;; (message "match: %S" match)
(cond
;; End of expression / statement
diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el
index a3e3423504..6b1553b561 100644
--- a/test/phps-mode-test-indent.el
+++ b/test/phps-mode-test-indent.el
@@ -188,6 +188,10 @@
"<?php\n$options = myFunction(\n array(array(\n 'options' =>
123\n ))\n);"
"Assignment with double-dimensional array with double arrow assignment
inside function call")
+ (phps-mode-test-indent--should-equal
+ "<?php\n// die('debug: ' . $debug\nif ($debug) {\n \n}\n"
+ "Line after commented out opening bracket line")
+
(phps-mode-test-indent--should-equal
"<?php\nswitch ($condition) {\n case 34:\n if ($item['Random'] %
10 == 0) {\n $attributes['item'] = ($item['IntegerValue'] / 10);\n
} else {\n $attributes['item'] =\n
number_format(($item['IntegerValue'] / 10), 1, '.', '');\n }\n
break;\n}\n"
"Switch case with conditional modulo expression")