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

Incorrect automatic caret indentation on a new line after a statement without an opening '{'. #878

Closed
rdxroman opened this issue Jul 12, 2017 · 4 comments

Comments

@rdxroman
Copy link

rdxroman commented Jul 12, 2017

After writing the following line
if (someCondition)
and then pressing the 'enter' key, the caret position in the new line will have the same indentation as the 'if' statement, which results in incorrect indentation.

Example:
Caret position is represented by the '|' sign.
Actual Result:

if (someCondition)
|

Expected Result:

if (someCondition)
    |

Same happens for other statements such as 'for' etc.

@sean-mcmanus
Copy link
Contributor

This is currently "by design". We don't add tabs after a newline is entered. Even typescript doesn't add a tab in these scenarios in VS Code. VS 2017 does add the tab though, so we'll probably support this eventually.

@rdxroman
Copy link
Author

If I enter the following:
if (someCondition) {
and press the 'enter' key, the result will be:

if (someCondition) {
    |

Is it considered a different scenario due to the explicit scope opening?

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Jul 12, 2017

Ah, I see. Yeah, the tab is being added by VS Code itself and not our extension. Using Enter after { is treated as started a scope so it is able to auto-indent, but whatever code is handling this doesn't understand one-line blocks that require indentation. Since the issue repros with Typescript and both languages share the same if/for/etc. statements, maybe VS Code itself could implement a fix. Maye this VS Code issue would address it: microsoft/vscode#16998 .

@sean-mcmanus
Copy link
Contributor

We'll track this with #883

@github-actions github-actions bot locked and limited conversation to collaborators Oct 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants