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

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

[elpa] externals/phps-mode 8d77fbdfdb 13/15: Improved indentation around


From: Christian Johansson
Subject: [elpa] externals/phps-mode 8d77fbdfdb 13/15: Improved indentation around switch case branches
Date: Fri, 4 Mar 2022 14:13:04 -0500 (EST)

branch: externals/phps-mode
commit 8d77fbdfdbe2795f997c1d61e686d38a3d3a1bde
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    Improved indentation around switch case branches
---
 TODO.md                       | 33 ---------------------------------
 phps-mode-indent.el           | 17 ++++++++---------
 test/phps-mode-test-indent.el |  1 -
 3 files changed, 8 insertions(+), 43 deletions(-)

diff --git a/TODO.md b/TODO.md
index ecfe6a0a21..5bac8dd60b 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,38 +1,5 @@
 # TODO
 
-## Indentation
-
-<?php
-
-if (true) {
-    $valid = true;
-    $variable = myFunction();
-    switch ($variable) {
-        case Object::CASE1:
-            throw new Exception(
-                'MyException'
-            );
-        case Object::Case2:
-            throw new \Exception(
-                'MyException2',
-            );
-        case Object::Case3:
-            $valid = false;
-            break;
-        case Object::Case4:
-            if (!Object2::validate($variable)) {
-                $valid = false;
-            }
-            break;
-        case Object::Case5:
-            $valid = false;
-            break;
-        case Object::Case6:
-            $valid = true;
-        break;
-    }
-}
-
 ## Code intelligence
 
 * Fix race-condition in incremental parser when running asynchronous using 
threads
diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index 250dbc6352..220cd95ade 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -532,17 +532,16 @@
 
            ;; Alternative control structures are always
            ;; indication of start of command
-           ((string-match-p
-             ")[\ t]*:[\t ]*$"
-             match)
+           ((or
+             (string-match-p
+              ")[\ t]*:[\t ]*$"
+              match)
+             (string-match-p
+              "[^:]:[\t ]*$"
+              match)) ;; Like case '50':
             (setq
              not-found
-             nil)
-            (setq
-             reference-line
-             (buffer-substring-no-properties
-              (line-beginning-position)
-              (line-end-position))))
+             nil))
 
            ;; A closing curly bracket is indicate of a distinct command
            ((string-match-p
diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el
index ede8b5933d..7fc32fb5d0 100644
--- a/test/phps-mode-test-indent.el
+++ b/test/phps-mode-test-indent.el
@@ -165,7 +165,6 @@
         (phps-mode-indent--get-previous-reference-command-line)
         "    $variable =")))
 
-    ;; TODO Make this pass
     (with-temp-buffer
       (insert "<?php\n\nif (true) {\n    $valid = true;\n    $variable = 
myFunction();\n    switch ($variable) {\n        case Object::CASE1:\n          
  throw new Exception(\n                'MyException'\n            );\n        
case Object::Case2:\n            throw new \\Exception(\n                
'MyException2',\n            );\n        case Object::Case3:\n            
$valid = false;\n            break;\n        case Object::Case4:\n            
if (!Object2::validate($variable))  [...]
       (goto-char 380)



reply via email to

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