Update indentation for PHP, JS, and TS #251465
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based on feedback in #136593 (comment).
@aiday-mar, as I mentioned in the linked PR, I wasn't super thrilled with doing it this way based on my thoughts in #43244 (comment) and #43244 (comment). However, I did some testing and VS Code will now unindent when
{
is pressed, which makes the original change to auto-indent still a change in expections, but something I can probably get used to. However, I noticed thatelse
wasn't handle consistently in JS and TS, so I fixed those in here (I see that it was mentioned in #43244 (comment) too). Personally, I can probably remove my extension that reverted the original auto-indentation changes and adjust to the new indentation this PR introduces, but based on feedback from #43244, there might be some backlash when this gets merged.Addresses #136592
if
,elseif
,else if
,while
,for
andforeach
. This also fixes an issue where hitting Enter on a blank line below a single lineif
(or other) results in an extra tab.*/
and blank line.else
to be consistent with handling ofif
statementsTesting
In the following PHP code, hit Enter on the last blank line, it will add a space in front of the new line.
Similarly, if you have the following code and hit Enter on the blank line, it will add a tab in front of the new line.
I also tested writing some
if
,else if
, andelse
statements in PHP, JS, and TS.