Skip to content

Update indentation for PHP, JS, and TS #251465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2025

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants