branch: externals/phps-mode
commit 3824abf1a70e064e95b952a8412934af0840c3c6
Author: Christian Johansson <[email protected]>
Commit: Christian Johansson <[email protected]>
Resolved indent with trailing parenthesis
---
phps-functions.el | 9 +++++----
phps-test-functions.el | 4 ++++
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/phps-functions.el b/phps-functions.el
index 497a0fd..8b20457 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -39,8 +39,7 @@
(defvar phps-mode/buffer-changes--start nil
"Start of buffer changes, nil if none.")
-;; TODO Should also format white-space inside the line, i.e. after function
declarations?
-;; TODO Should indent doc blocks with 1 space
+;; TODO Also format white-space inside the line, i.e. after function
declarations?
(defun phps-mode/indent-line ()
"Indent line."
(let ((data (phps-mode/get-point-data)))
@@ -73,9 +72,11 @@
(while (and valid-tokens
(<= token-number end-token-number))
(let ((token (car (nth token-number phps-mode/lexer-tokens)))
- (token-start (car (cdr (nth token-number
phps-mode/lexer-tokens)))))
+ (token-start (car (cdr (nth token-number
phps-mode/lexer-tokens))))
+ (token-end (cdr (cdr (nth token-number
phps-mode/lexer-tokens)))))
(when (and valid-tokens
- (>= token-start (point))
+ (or (>= token-start (point))
+ (>= token-end (point)))
(not (or
(string= token "{")
(string= token "}")
diff --git a/phps-test-functions.el b/phps-test-functions.el
index 5b695cc..17cced3 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -186,6 +186,10 @@
(goto-char 50)
(should (equal (list (list t 0 0 0 nil nil) (list t 0 0 0 nil nil))
(phps-mode/get-point-data))))
+ (phps-mode/with-test-buffer
+ "<?php\n$variable = array(\n'random4');\n$variable = true;\n"
+ (goto-char 29)
+ (should (equal (list (list t 0 1 0 4 nil) (list t 0 0 0 7 nil))
(phps-mode/get-point-data))))
)
;; TODO Add tests for all examples here: https://www.php-fig.org/psr/psr-2/