Skip to content

Conversation

@ssigwart
Copy link
Contributor

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 that else 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

  • For PHP, auto-indent after if, elseif, else if, while, for and foreach. This also fixes an issue where hitting Enter on a blank line below a single line if (or other) results in an extra tab.
  • For PHP, extra space after */ and blank line.
  • For JS/TS, auto-indent for else to be consistent with handling of if statements

Testing

In the following PHP code, hit Enter on the last blank line, it will add a space in front of the new line.

/**
 * PHPDoc
 */

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.

if (1)
	1;

I also tested writing some if, else if, and else statements in PHP, JS, and TS.

Addresses microsoft#136592

- For PHP, auto-indent after `if`, `elseif`, `else if`, `while`, `for` and `foreach`. This also fixes an issue where hitting Enter on a blank line below a single line `if` (or other) results in an extra tab.
- For PHP, extra dot after `*/` and blank line.
- For JS/TS, auto-indent for `else` to be consistent with handling of `if` statements
@aiday-mar
Copy link
Contributor

Hi @ssigwart thank you for the PR! I will have a look!

@aiday-mar aiday-mar enabled auto-merge (squash) June 17, 2025 09:05
@vs-code-engineering vs-code-engineering bot added this to the June 2025 milestone Jun 17, 2025
@aiday-mar aiday-mar merged commit 7c43b02 into microsoft:main Jun 17, 2025
7 checks passed
@ssigwart ssigwart deleted the singleLineConfig branch June 17, 2025 18:49
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Aug 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

4 participants