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
While working on adding support for the improved auto-indent mentioned here to the Haxe extension, I noticed it doesn't work well with Allman bracket style ({ in new line). This is the behavior for both TS and JS:
The expected behavior would be to un-indent again when the { is typed, take Sublime for example:
The Reindent lines command also produces incorrect indentation for lines that are already typed:
Reacted by Spencer Evans, Damian, David St-Louis, Dmytro Kozlov, Futureglobe and Roman Starkov
Jens Fischer (@Gama11) We added indentNextLinePattern: /^\s*(for|while|if|else)\b(?!.*[;{}]\s*(\/\/.*|\/[*].*[*]\/\s*)?$)/ which means anyline matches such rule will only indent next line. Then we can support below case in JavaScript
if (true)
if (true)
if (true)
console.log('a')
console.log('b')
If you want to have Allman bracket style support in an extension, you may want to remove this case from indentNextLinePattern rule.
Peng Lyu (@rebornix) It seems it should be possible to support both. You'd have to remove the indent from indentNextLinePattern again when a { is typed in a new line, like Sublime does in the .gif I included. IntelliJ also handles this well:
Reacted by Peng Lyu, Tom, Spencer Evans and Yang09701194
Peng Lyu (@rebornix) Thanks! This is probably not much of an issue for TS / JS, but for other C-Style languages (Java, C#...), Allman Style is fairly common.
Quicky fix hack seems to work: (on Mac) edit the file "~/Applications/Visual Studio Code.app//Contents/Resources/app/extensions/typescript/out/typescriptMain.js", comment out these two lines:
just got 1.15 update... unfortunately this bug is still there...
The editor is barely usable with this bug! Can we boost priority on this somehow?
I'll try Alex Clark (@aclarkxyz) hack for now
fyi setting increaseIndentPattern and decreaseIndentPattern to "" in language-configuration.json for cpp and setting "editor.autoindent" to true restored the pre-1.14 behavior. This is the desired behavior.
Jens Fischer (@Gama11) for this particular issue, we already removed indentation rules for Allman bracket style, then now pressing enter after ) will not add indentation.
Feel free to open new issues for other unexpected behaviors, or you can disable the auto-indent by editor.autoIndent as one set of indentation rules won't work for everyone.
So there's no plans for getting auto-indentation on par with Sublime's / IntelliJ's behavior shown in the .gifs? Just removing the feature altogether (for this case) doesn't seem like a great solution...
Activity
rebornix commentedon Jun 26, 2017
Jens Fischer (@Gama11) We added
indentNextLinePattern: /^\s*(for|while|if|else)\b(?!.*[;{}]\s*(\/\/.*|\/[*].*[*]\/\s*)?$)/which means anyline matches such rule will only indent next line. Then we can support below case in JavaScriptIf you want to have Allman bracket style support in an extension, you may want to remove this case from
indentNextLinePatternrule.rebornix commentedon Jun 26, 2017
The reindent one is a bug.
Gama11 commentedon Jun 26, 2017
Peng Lyu (@rebornix) It seems it should be possible to support both. You'd have to remove the indent from
indentNextLinePatternagain when a{is typed in a new line, like Sublime does in the .gif I included. IntelliJ also handles this well:rebornix commentedon Jun 26, 2017
Jens Fischer (@Gama11) I reconsidered it, it's a valid feature request :) Thanks for all the info.
Gama11 commentedon Jun 26, 2017
Peng Lyu (@rebornix) Thanks! This is probably not much of an issue for TS / JS, but for other C-Style languages (Java, C#...), Allman Style is fairly common.
aclarkxyz commentedon Jul 13, 2017
Please fix: VSCode was a great editor until this bug slipped in; this may seem like a minor thing, but it's really not...
aclarkxyz commentedon Jul 13, 2017
Quicky fix hack seems to work: (on Mac) edit the file "~/Applications/Visual Studio Code.app//Contents/Resources/app/extensions/typescript/out/typescriptMain.js", comment out these two lines:
A semblance of sanity appears to be restored.
1 remaining item
Gama11 commentedon Aug 9, 2017
Peng Lyu (@rebornix) Missing
editor-indentationlabel? :)davidstlyoui commentedon Aug 10, 2017
just got 1.15 update... unfortunately this bug is still there...
The editor is barely usable with this bug! Can we boost priority on this somehow?
I'll try Alex Clark (@aclarkxyz) hack for now
davidstlyoui commentedon Aug 10, 2017
Also this issue is wrongly marked as "Feature Request".
This is a regression bug, not a feature request.
coderas commentedon Aug 23, 2017
definitely a regression bug, I'm am seeing this break formats on paste too. Used to work beautifully.
captainparticles commentedon Sep 27, 2017
I'm seeing this bug on cpp files. Same issue as described by op. Any fix inbound, or a workaround in the meantime?
captainparticles commentedon Sep 27, 2017
fyi setting increaseIndentPattern and decreaseIndentPattern to "" in language-configuration.json for cpp and setting "editor.autoindent" to true restored the pre-1.14 behavior. This is the desired behavior.
rebornix commentedon Dec 1, 2017
Jens Fischer (@Gama11) for this particular issue, we already removed indentation rules for Allman bracket style, then now pressing enter after
)will not add indentation.Feel free to open new issues for other unexpected behaviors, or you can disable the auto-indent by
editor.autoIndentas one set of indentation rules won't work for everyone.Gama11 commentedon Dec 1, 2017
So there's no plans for getting auto-indentation on par with Sublime's / IntelliJ's behavior shown in the .gifs? Just removing the feature altogether (for this case) doesn't seem like a great solution...