[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode cc3bf03786 123/212: Improved indentation afte
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode cc3bf03786 123/212: Improved indentation after ending assignment expression |
Date: |
Wed, 26 Jan 2022 01:51:12 -0500 (EST) |
branch: externals/phps-mode
commit cc3bf037861fbbedc9eaaba24a1c2e429777aaa8
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Improved indentation after ending assignment expression
---
phps-mode-indent.el | 31 ++++++++++++++++++-------------
test/phps-mode-test-indent.el | 4 ++--
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index 7b7318eb69..a56a14534f 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -250,6 +250,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-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)
;; (message "previous-indentation: %S" previous-indentation)
@@ -930,16 +931,15 @@
;; When we have an assignment
;; keep track if bracket was opened on first
;; line
- (when (and
- is-assignment
- (string-match-p
- "[([]"
- (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position))))
- (setq
- bracket-opened-on-first-line
- t))
+ (when is-assignment
+ (let ((start-bracket-count
+ (phps-mode-indent--get-string-brackets-count
+ (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position)))))
+ (setq
+ bracket-opened-on-first-line
+ (> start-bracket-count 0))))
;; echo 'there' .
;; 'here';
@@ -994,9 +994,14 @@
;; $myObject->myFunction()
;; ->myFunction2()
- ((string-match-p
- "->"
- previous-line-string)
+ ;; but ignore
+ ;; $myObject->test(
+ ;; 'here'
+ ((and
+ (not previous-line-ends-with-opening-bracket)
+ (string-match-p
+ "->"
+ previous-line-string))
(let ((not-found t)
(started-chaining-on-this-line t)
(is-assignment)
diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el
index f74feaa133..3ba781f7b2 100644
--- a/test/phps-mode-test-indent.el
+++ b/test/phps-mode-test-indent.el
@@ -202,11 +202,11 @@
"Indentation for chained object operators in assignment with method call
with arguments")
(phps-mode-test-indent--should-equal
- "<?php\n\n$myResult = !empty($myVar->myMethod3)\n && $myVar->myMethod\n
&& $myVar->myMethod2;\n"
+ "<?php\n\n$myResult = !empty($myVar->myMethod3)\n && $myVar->myMethod\n
&& $myVar->myMethod2;\necho 'here';"
"Indentation for chained object operators in assignment")
(phps-mode-test-indent--should-equal
- "<?php\n$array = [\n 'second' => [\n 'hello' => true\n
]\n];\n\n$array = array(\n 'second' => array(\n 'third' => true\n
)\n);"
+ "<?php\n$array = [\n 'second' => [\n 'hello' => true\n
]\n];\n\n$array = array(\n 'second' => array(\n 'third' => true\n
)\n);"
"Indent multi-dimensional arrays without trailing commas")
(phps-mode-test-indent--should-equal
- [elpa] externals/phps-mode a65c8af308 008/212: Extract ast code into separate file and test, (continued)
- [elpa] externals/phps-mode a65c8af308 008/212: Extract ast code into separate file and test, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 23c001c33f 037/212: Moved parser SDT to separate file, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 261121f096 056/212: Fixed incorrect information in debug output in test, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e8a47de694 052/212: Work on supported arrow functions for bookkeeping via AST, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 5686703a6b 074/212: Passing bookkeeping via AST for $this inside arrow function body inside class method, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode a9d0e941df 066/212: Started on SDT for static variables statement, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode a8fecdfd68 055/212: Bookkeeping of variables inside arrow functions now working, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e42646dc3a 058/212: Added SDT for isset() and empty(), Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 9ad46d061e 057/212: Bookkeeping via AST passing two more tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 806bb902b3 122/212: Improved indentation for chaining objects, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode cc3bf03786 123/212: Improved indentation after ending assignment expression,
Christian Johansson <=
- [elpa] externals/phps-mode 3162dca5c4 159/212: Added two more failing indentation tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 1e44021653 163/212: Added more failing indent tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e7aff3f69d 157/212: Passed more indentation tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode db7121941c 156/212: Passing indention on line after not equals condition, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d072fe5315 136/212: Improved indentation around array elements, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode f880ba2d62 164/212: Improved indentation on lines after assignment that ends with closing bracket, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode db019887af 170/212: Passed new indentation tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 781356557c 194/212: More adjustments to indent helper to find previous command, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 0735959c08 209/212: Using silent cache write, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e3bf9e8fed 059/212: SDT rules for some more infix operations, Christian Johansson, 2022/01/26