From c5c5708ae437d13275149910fc461311c2b9254a Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 1 Dec 2023 18:06:03 +0100 Subject: [PATCH 1/3] [PHP] Fix indentation after `else if():` Follow up for #1932 to also correctly increase indentation level after `else if`. --- PHP/Indentation Rules.tmPreferences | 2 +- PHP/tests/syntax_test_indentation.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/PHP/Indentation Rules.tmPreferences b/PHP/Indentation Rules.tmPreferences index d0582b2274..d76b2d7872 100644 --- a/PHP/Indentation Rules.tmPreferences +++ b/PHP/Indentation Rules.tmPreferences @@ -46,7 +46,7 @@ | # OR ^\s* (<\?(php)?\s+)? # the beginning of the line followed by any amount of whitespace and an optional PHP open tag ( (?: - (?:else)?if\s*\g|else # PHP "if" related statements + (?:else\s*)?if\s*\g|else # PHP "if" related statements )\s*:(?!.*\bendif\b) # followed by a colon, not followed by an "endif" anywhere on the line | (?foreach|for|switch|while)\s*\g # PHP control keywords, followed by balanced parens diff --git a/PHP/tests/syntax_test_indentation.php b/PHP/tests/syntax_test_indentation.php index aedf61266a..1e7d6cefbd 100644 --- a/PHP/tests/syntax_test_indentation.php +++ b/PHP/tests/syntax_test_indentation.php @@ -5,6 +5,8 @@ asdfadf asdf + + asdf qwfpg From 740be3c1043daeeee03dc45293a5d2083ed16e32 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 1 Dec 2023 18:11:21 +0100 Subject: [PATCH 2/3] [PHP] Drop unsupported indentation rule This commit removes unsupported `indentNextLinePattern` pattern. --- PHP/Indentation Rules.tmPreferences | 3 --- 1 file changed, 3 deletions(-) diff --git a/PHP/Indentation Rules.tmPreferences b/PHP/Indentation Rules.tmPreferences index d76b2d7872..7ebe778d39 100644 --- a/PHP/Indentation Rules.tmPreferences +++ b/PHP/Indentation Rules.tmPreferences @@ -54,9 +54,6 @@ ) ]]> - indentNextLinePattern - - bracketIndentNextLinePattern (?x) ^ \s* \b(if|while|else|elseif|foreach)\b [^;]* $ From 009343f045042bd2ec357e3902b9f316a00e6646 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 1 Dec 2023 18:34:05 +0100 Subject: [PATCH 3/3] [PHP] Tweak comment positions --- PHP/Indentation Rules.tmPreferences | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PHP/Indentation Rules.tmPreferences b/PHP/Indentation Rules.tmPreferences index 7ebe778d39..10c599be02 100644 --- a/PHP/Indentation Rules.tmPreferences +++ b/PHP/Indentation Rules.tmPreferences @@ -19,7 +19,7 @@ \s* [}\])] # optionally followed by whitespace, followed by a closing: curly brace, square bracket or paren | # OR \s* (<\?(php)?\s+)? # an optional PHP open tag - (else(\s*if)?\b.*:\s*($|//|/\*|\?>)|(end(if|for(each)?|switch|while))\b) # followed by an keyword that ends a control flow block + (else(\s*if)?\b.*:\s*($|//|/\*|\?>)|(end(if|for(each)?|switch|while))\b) # followed by an keyword that ends a control flow block ) ]]> @@ -46,7 +46,7 @@ | # OR ^\s* (<\?(php)?\s+)? # the beginning of the line followed by any amount of whitespace and an optional PHP open tag ( (?: - (?:else\s*)?if\s*\g|else # PHP "if" related statements + (?:else\s*)?if\s*\g|else # PHP "if" related statements )\s*:(?!.*\bendif\b) # followed by a colon, not followed by an "endif" anywhere on the line | (?foreach|for|switch|while)\s*\g # PHP control keywords, followed by balanced parens