Skip to content
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

Auto indent in JS, follow up #46401

Open
qraynaud opened this issue Mar 23, 2018 · 0 comments
Open

Auto indent in JS, follow up #46401

qraynaud opened this issue Mar 23, 2018 · 0 comments
Assignees
Labels
editor-autoindent Editor auto indentation issues javascript JavaScript support issues on-unit-test typescript Typescript support issues under-discussion Issue is under discussion for relevance, priority, approach

Comments

@qraynaud
Copy link

This is a follow up of bug #29390 because I think the change in behavior is not what most users would like to have. I'm a big fan of single line blocks without brackets.

Yes, I know some consider this a huge security risk and bad practice, and I have a eslint looking for two liners indented without braces so I feel safe (and in 15+ years of dev I never had a bug due to that specific issue).

I don't think your editor should decide for you how you should code. @Gama11 posted a gif of how Sublime Text handles that specific issue to support all known styles at once. This probably requires a more involved solution but I would like it to be considered (at least) before being left out.

Here, for the record, I post back the gif he posted:
sublime code style handling

As you can see, when you write an if, it auto indents the line if you press Enter (previous behavior of vscode). Then if you make a single line and press enter, it will automatically deindent. But if you immediately put in a bracket instead (second example of the gif), it deindents it, effectively supporting allman style by adapting to it after the fact. This prevents the issue reported in bug #36505 that was closed by lack of an obvious solution.

But fixing the allman style and breaking instead single line blocks is not really optimal. Even more so because I believe we are more to use single line blocks that they are allman styles guys (in JS/TS).

@vscodebot vscodebot bot added editor editor-autoindent Editor auto indentation issues labels Mar 23, 2018
@rebornix rebornix added the under-discussion Issue is under discussion for relevance, priority, approach label Sep 18, 2018
@aiday-mar aiday-mar assigned aiday-mar and unassigned rebornix Mar 8, 2024
@aiday-mar aiday-mar added javascript JavaScript support issues typescript Typescript support issues labels Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor-autoindent Editor auto indentation issues javascript JavaScript support issues on-unit-test typescript Typescript support issues under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

4 participants