[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 ()
- [elpa] externals/phps-mode b9f74656ad 02/17: Added ONUM regex, (continued)
- [elpa] externals/phps-mode b9f74656ad 02/17: Added ONUM regex, Christian Johansson, 2022/07/26
- [elpa] externals/phps-mode 4f936cd5cd 06/17: Fixed byte-compilation issue with new lexer rules, Christian Johansson, 2022/07/26
- [elpa] externals/phps-mode 3d4576eac6 08/17: Another fix for readonly, Christian Johansson, 2022/07/26
- [elpa] externals/phps-mode e50ecb53be 09/17: More debugging byte-compilation issue, Christian Johansson, 2022/07/26
- [elpa] externals/phps-mode 3f9898cd2a 11/17: Added instructions of how to update lexer rules, Christian Johansson, 2022/07/26
- [elpa] externals/phps-mode f070d688a4 13/17: Added TODO items, Christian Johansson, 2022/07/26
- [elpa] externals/phps-mode e84ba21c7d 15/17: Updated TODO, Christian Johansson, 2022/07/26
- [elpa] externals/phps-mode a56b01bd3f 17/17: Updated version and date, Christian Johansson, 2022/07/26
- [elpa] externals/phps-mode e5fda9efb3 10/17: New lexer tokens working after byte-compilation, Christian Johansson, 2022/07/26
- [elpa] externals/phps-mode 777c88da24 12/17: Fixed byte-compilation warning, Christian Johansson, 2022/07/26
- [elpa] externals/phps-mode a682f890c1 16/17: Fixed indentation for enumerations,
Christian Johansson <=