You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bugIssue identified by VS Code Team member as probable bugeditor-autoindentEditor auto indentation issuesfeature-requestRequest for new features or functionalityverifiedVerification succeeded
@wallverb I can not reproduce this problem.
It is possible that this issue is caused by an installed extension. Can you try to run VS Code without extensions? From the command line, execute: code --disable-extensions and try your steps again to see if it reproduces. If you see it is an issue with the extension, please file it against the extension repository itself.
@wallverb I can reproduce with your snippet. This issue is independent from TypeScript.
The snippet has inconsistent indentation: 6 lines seem to use 4 spaces for one indentation level, 3 lines use 2 spaces. Since you are probably using the default editor setting "editor.detectIndentation": true, VS Code determines the tab size to be 4 (you can see this in the editor's status bar at the bottom).
Since the outdent operation has to move the lines to valid tab positions, the result is unexpected but correct.
Your expected behaviour would require a tabSize of 2. To achieve this, you will have to use these settings:
Right, I knew it was related to mix of 2 spaces and 4 spaces tabs - but even that assuming that VSCode detected Spaces: 4 it shouldn't "break" children
In other words: (assuming Spaces: 4)
Starting state:
Current outdent operation results in:
(notice how children got unaligned)
Ideal situation would be if VSCode could "fix" the indentation difference and for example create this output:
("data" was only moved by 2 spaces left to fit into 4 spaces tab and children got "fixed")
or at least just move everything by 2 spaces to the left (so `"data" follows the 4 spaces tab) or (what Atom does) - just move everything 4 spaces to the left - without "breaking children"
IMO dumb indentation should be the default, since that's the default behavior for most editors, and is least likely to break existing formatting. Especially in languages like Clojure where partial indents are very prevalent (see #15598).
That's my 2c, but as long as it's configurable at all as a setting, I can live with it.
Reacted by Robin Munn, Jan Niklas Hasse, Brent Jubinville and LegoChicken
Similar problem in C++ (also C). For example,
Do outdent:
Second parameter was aligned, now isn't. A dumb indentation should be default. This would make it work as I expect, i.e. not change the layout. When one of the lines doesn't contain whitespace either stop working or start stripping whitespace (in tab size steps) from the other lines. This is behaviour in SlickEdit, which I find useful occasionally.
bugIssue identified by VS Code Team member as probable bugeditor-autoindentEditor auto indentation issuesfeature-requestRequest for new features or functionalityverifiedVerification succeeded
Activity
weinand commentedon Jul 17, 2016
@wallverb I can not reproduce this problem.
It is possible that this issue is caused by an installed extension. Can you try to run VS Code without extensions? From the command line, execute:
code --disable-extensionsand try your steps again to see if it reproduces. If you see it is an issue with the extension, please file it against the extension repository itself.normalser commentedon Jul 17, 2016
Andre Weinand (@weinand) here are the steps to recreate:
mkdir testcode --disable-extensions testtest.tstest.ts5 - Try to outdent:
If works then proceed to step 6
6 - Close VSCode
7 -
code --disable-extensions test8 - Try to outdent again
I'm getting the issue from above screenshots
weinand commentedon Jul 17, 2016
@wallverb I can reproduce with your snippet. This issue is independent from TypeScript.
The snippet has inconsistent indentation: 6 lines seem to use 4 spaces for one indentation level, 3 lines use 2 spaces. Since you are probably using the default editor setting
"editor.detectIndentation": true, VS Code determines the tab size to be 4 (you can see this in the editor's status bar at the bottom).Since the outdent operation has to move the lines to valid tab positions, the result is unexpected but correct.
Your expected behaviour would require a tabSize of 2. To achieve this, you will have to use these settings:
normalser commentedon Jul 17, 2016
Right, I knew it was related to mix of 2 spaces and 4 spaces tabs - but even that assuming that VSCode detected
Spaces: 4it shouldn't "break" childrenIn other words: (assuming
Spaces: 4)Starting state:

Current outdent operation results in:
(notice how children got unaligned)
Ideal situation would be if VSCode could "fix" the indentation difference and for example create this output:
(
"data"was only moved by 2 spaces left to fit into 4 spaces tab and children got "fixed")or at least just move everything by 2 spaces to the left (so `"data" follows the 4 spaces tab) or (what Atom does) - just move everything 4 spaces to the left - without "breaking children"
alexdima commentedon Aug 9, 2016
This issue touches on two topics:
I think both behaviours have pros and cons. i.e. I have a feeling they should be expressed as settings.
lewisl9029 commentedon Nov 17, 2016
IMO dumb indentation should be the default, since that's the default behavior for most editors, and is least likely to break existing formatting. Especially in languages like Clojure where partial indents are very prevalent (see #15598).
That's my 2c, but as long as it's configurable at all as a setting, I can live with it.
BillDenton commentedon Jan 26, 2017
Similar problem in C++ (also C). For example,


Do outdent:
Second parameter was aligned, now isn't. A dumb indentation should be default. This would make it work as I expect, i.e. not change the layout. When one of the lines doesn't contain whitespace either stop working or start stripping whitespace (in tab size steps) from the other lines. This is behaviour in SlickEdit, which I find useful occasionally.
alexdima commentedon Sep 27, 2017
Setting
"editor.useTabStops": falsegives the desired behaviour. It has been shipped since quite a while, I forgot to update this issue.