Skip to content

Commit 16f501e

Browse files
committed
Fix single line if/else and loop indentation
1 parent 2260d7c commit 16f501e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

extensions/php/language-configuration.json

+9
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@
7676
"indent": "none",
7777
"removeText": 1
7878
}
79+
},
80+
{
81+
// Decrease indentation after single line if/else if/else, for, foreach, or while
82+
"previousLineText": "^\\s*(((else ?)?if|for(each)?|while)\\s*\\(.*\\)\\s*|else\\s*)$",
83+
// But make sure line doesn't have braces or is not another if statement
84+
"beforeText": "^\\s+([^{i\\s]|i(?!f\\b))",
85+
"action": {
86+
"indent": "outdent"
87+
}
7988
}
8089
]
8190
}

extensions/typescript-basics/language-configuration.json

+9
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,15 @@
188188
"action": {
189189
"indent": "indent"
190190
}
191+
},
192+
{
193+
// Decrease indentation after single line if/else if/else, for, or while
194+
"previousLineText": "/^\\s*(((else )?if|for|while)\\s*\\(.*\\)\\s*|else\\s*)$/",
195+
// But make sure line doesn't have braces or is not another if statement
196+
"beforeText": "/^\\s+([^{i\\s]|i(?!f\\b))/",
197+
"action": {
198+
"indent": "indentOutdent"
199+
}
191200
}
192201
]
193202
}

0 commit comments

Comments
 (0)