emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phps-mode 81c7179 293/405: Fixed indentation bug with a


From: Stefan Monnier
Subject: [elpa] externals/phps-mode 81c7179 293/405: Fixed indentation bug with assignment of square array in function argument
Date: Sat, 13 Jul 2019 10:00:35 -0400 (EDT)

branch: externals/phps-mode
commit 81c7179ae858710d080ad353a4a95ac45b30f5da
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>

    Fixed indentation bug with assignment of square array in function argument
---
 phps-mode-functions.el      | 11 +++++++++--
 phps-mode-test-functions.el |  6 +++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index d242174..89a5501 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -109,6 +109,8 @@
               (allow-custom-column-increment nil)
               (allow-custom-column-decrement nil)
               (in-assignment nil)
+              (in-assignment-round-bracket-level nil)
+              (in-assignment-square-bracket-level nil)
               (in-assignment-level 0)
               (in-class-declaration nil)
               (in-class-declaration-level 0)
@@ -442,7 +444,10 @@
                 ;; Keep track of assignments
                 (if in-assignment
                     (if (or (string= token ";")
-                            (< round-bracket-level in-assignment))
+                            (and (string= token ")")
+                                 (<= round-bracket-level 
in-assignment-round-bracket-level))
+                            (and (string= token"]")
+                                 (<= square-bracket-level 
in-assignment-square-bracket-level)))
                         (progn
                           (setq in-assignment nil)
                           (setq in-assignment-level 0))
@@ -453,7 +458,9 @@
                   (when (and (not after-special-control-structure)
                              (string= token "="))
                     ;; (message "Started assignment")
-                    (setq in-assignment round-bracket-level)
+                    (setq in-assignment t)
+                    (setq in-assignment-round-bracket-level 
round-bracket-level)
+                    (setq in-assignment-square-bracket-level 
square-bracket-level)
                     (setq in-assignment-level 1)))
 
                 ;; Did we encounter a token that supports extra special 
alternative control structures?
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 0d9ada1..792ab9f 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -222,10 +222,10 @@
    ;; (message "Indent: %s" (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)))
    (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)) (5 (0 0)) (6 (1 
0)) (7 (1 0)) (8 (2 0)) (9 (1 0)) (10 (0 0))) (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)))))
 
-  ;; TODO Fix this
+  ;; TODO Fix this below
 
   (phps-mode-test-with-buffer
-   "<?php\nnamespace Vendor\Package;\n\nclass ClassName\n{\n    public 
function aVeryLongMethodName(\n        ClassTypeHint $arg1,\n        &$arg2,\n  
      array $arg3 = []\n    ) {\n        // method body\n    }\n}"
+   "<?php\nnamespace Vendor\\Package;\n\nclass ClassName\n{\n    public 
function aVeryLongMethodName(\n        ClassTypeHint $arg1,\n        &$arg2,\n  
      array $arg3 = []\n    ) {\n        // method body\n    }\n}"
    "PSR-2 : 4.4. Method Arguments : Example 2"
    (message "Indent: %s" (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)))
    (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)) (5 (0 0)) (6 (1 
0)) (7 (2 0)) (8 (2 0)) (9 (2 0)) (10 (1 0)) (11 (2 0)) (12 (1 0)) (13 (0 0))) 
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
@@ -769,7 +769,7 @@
 (defun phps-mode-test-functions ()
   "Run test for functions."
   ;; (setq debug-on-error t)
-  ;; (setq phps-mode-functions-verbose t)
+  (setq phps-mode-functions-verbose t)
   (phps-mode-test-functions-get-lines-lindent-if)
   (phps-mode-test-functions-get-lines-indent-classes)
   (phps-mode-test-functions-get-lines-indent-inline-if)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]