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 indentation is not smart enough #56769

Closed
minj opened this issue Aug 19, 2018 · 3 comments
Closed

Auto indentation is not smart enough #56769

minj opened this issue Aug 19, 2018 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-autoindent Editor auto indentation issues wont-fix

Comments

@minj
Copy link

minj commented Aug 19, 2018

  • VSCode Version: 1.26.1
  • OS Version: Linux

It just follows the last line.

Problem can be reproduced by examples @ #36505 (comment)

I am purposefully creating a duplicate of #36505 since I find the resolution to it lacking.
Duplicate? Of what? How to work/hack around this?

I don't believe editor's job is to force code style on people.

It seems to be something a capable editor should be... capable to do. This is a UX breaker for me.

@rebornix
Copy link
Member

rebornix commented Sep 6, 2018

Can you try setting editor.autoIndent to false to see if it mitigates the problem you run into?

I agree that indentation is related to code styles.

@rebornix rebornix added bug Issue identified by VS Code Team member as probable bug editor-autoindent Editor auto indentation issues labels Sep 6, 2018
@minj
Copy link
Author

minj commented Mar 16, 2019

Wanted to post an update since it's been 6 months...

The paste problems seem to be resolved. Here's the snippet with current issues:

// pretend CARET is the text cursor
// if you press enter, the new line isn't indented (it should be)
if (x) CARET

// if you press enter, the new line is indented (it shouldn't be)
if (x)
    return; CARET

// if you...
// - press enter, the new line is indented (it shouldn't be)
if (x)
    return;
CARET

FYI, disabling editor.autoIndent does 'solve' the last two problems but that kind of defeats the purpose, doesn't it?

@rebornix
Copy link
Member

rebornix commented Nov 3, 2020

This is due to the limited architecture (regex based indentation rules and only support limited code styles), we may want to consider using formatters if they exist for indenation adjustment (if interested, we can discuss in #19847).

For this particular issue, if the indentation rules are leading to more trouble than having no auto indent, you can set editor.autoIndent to advanced to disable the regex based indentation adjustment or use auto formatting (editor.formatOnType, editor.formatOnPaste). As we don't have an easy good-enough fix for it, we close it for now and explore better solutions through issues like (#19847 and #34621).

@rebornix rebornix closed this as completed Nov 3, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-autoindent Editor auto indentation issues wont-fix
Projects
None yet
Development

No branches or pull requests

2 participants