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

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

[elpa] externals/phps-mode a682f890c1 16/17: Fixed indentation for enume


From: Christian Johansson
Subject: [elpa] externals/phps-mode a682f890c1 16/17: Fixed indentation for enumerations
Date: Tue, 26 Jul 2022 08:44:20 -0400 (EDT)

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

    Fixed indentation for enumerations
---
 TODO.md                       | 2 --
 phps-mode-indent.el           | 6 +++++-
 test/phps-mode-test-indent.el | 4 ++++
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/TODO.md b/TODO.md
index da48646877..805f5f8299 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,7 +1,5 @@
 # TODO
 
-* Fix indentation of enum cases
-
 ## Code intelligence
 
 * Bookkeeping of chained object operators like WC()->cart->subtotal
diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index 220cd95ade..f0ea149d44 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -1126,7 +1126,8 @@
                ;; default:
                ((and
                  (not previous-line-ends-with-opening-bracket)
-                 (not (string-match-p ":[\t ]*$" previous-line-string))
+                 (not (string-match-p ")[\t ]*:[\t ]*$" previous-line-string))
+                 (not (string-match-p "^[\t ]*case[\t ]*" 
previous-line-string))
                  (or
                   (string-match-p
                    "^[\t ]*case[\t ]+.*\\(;\\|:\\)[\t ]*$"
@@ -1312,6 +1313,9 @@
                ;; LINE AFTER ALTERNATIVE CASE DEFINITION
                ;; switch ($array):
                ;;     case 'Something';
+               ;; or
+               ;; switch ($array):
+               ;;     case 'Something':
                ((and
                  (string-match-p
                   "^[\t ]*\\(case.+\\|default\\)\\(;\\|:\\)[\t ]*$"
diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el
index 7fc32fb5d0..dbee99a611 100644
--- a/test/phps-mode-test-indent.el
+++ b/test/phps-mode-test-indent.el
@@ -792,6 +792,10 @@
    "<?php\nif (true) {\n    /*\n    was here\n    */\n    echo 'there';\n}"
    "Line after closing multi-row comment")
 
+  (phps-mode-test-indent--should-equal
+   "<?php\nenum Suit\n{\n    case Hearts;\n    case Diamonds;\n    case 
Clubs;\n    case Spades;\n}"
+   "Basic Enumeration")
+
   )
 
 (defun phps-mode-test-indent--get-lines-indent-psr-2 ()



reply via email to

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