-
Notifications
You must be signed in to change notification settings - Fork 677
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
Indentation removed on empty lines when Format Document is used #1980
Comments
Possible duplicate of #1680 |
See text highlighting at end of attached gif, doesn't appear to be caret positioning but actual deletion of the spaces. |
@poodle-chowder : The goal of the whitespace formatter is to remove superfluous whitespace. So, the behavior that you're seeing where unnecessary indentation at the starts of lines is removed is working as designed. I suspect that the real issue here is really the same as #1680, where the indentation is removed on the line where the caret appears, shifting it to the left. |
@DustinCampbell Understood. I think the heart of the issue is that whether VS does not seem to consider the indents leading up to a block's indentation level to be superfluous, but VSCode formats to 0 indent even in the middle of a code block. This seems like odd behavior to me. Is the agenda to keep workflow consistent between the two? |
Not exactly. The intent is to keep the formatting similar for C# between Visual Studio and Visual Studio Code. C#'s formatter has always removed extra indentation, but there's special behavior on the line that the caret is on. |
Is there any alternative to format documents without removing whitespace on empty lines now? Or even just a 'format without removing whitespace anywhere at all'? I have tried a lot of solutions and disabling/enabling whitespace trimming settings, but whitespace on blank lines is always deleted. |
I've also tried everything but nothing works. Any ideas? |
@Magenda Right now i have just accepted writing lines ugly, and then using ctrl-s to immediately format them and put them back at the right position again |
I would like to have the option to not have whitespace removed on empty lines, regardless of where the caret is located. I frequently leave empty lines between code blocks so as to make my code more readable, oftentimes adding additional code in between these blocks at a later time. Having to re-tab a bunch of times to start that new code is definitely not preferred. This was a feature in VS, and I miss it greatly in VS Code. |
I've been looking for a solution for weeks. It's driving me literally insane. Please fix this. |
I, too, would like a solution to this. It's very, very annoying, especially when combined with Vim. |
This bug is infuriating, and nothing has been done about it for years?! The people who maintain this project must not actually use it for real-world, day-to-day work. I don’t see how anyone can stand this behavior. It seems like this issue has just been blamed on some other issue and so nothing is being done about it. Unacceptable people! |
I just checked Visual Studio, indeed it deletes whitespaces, it's just it keeps caret on correct indentation level. So it's indeed not an extension fault but VSCode itself. |
I like empty lines to be removed (with format document) while editing JSON files. Now for some reason this has behavior has been removed. |
This wouldn't be an issue if VSCode had a behavior similar to IntelliJ/Android Studio. |
It's 2020 and there is still no fix to this bug as i am currently experiencing the same issue. I can't believe it. This is literally driving me nuts. One moment it was working the next I know it wasn't. |
Any news on this? I cannot switch to VSCode with this. It would drive me insane. |
I also would like this to be fixed. I really think having "fake" indentation is the way to go. |
I encourage everyone interested in this fuctionality to upvote the following vscode issue - microsoft/vscode#13960 |
But virtual space is not the same thing - this issue highlights that VS Code is formatting out indents on blank lines... |
This is a very annoying problem, and makes interoperability with Visual Studio almost impossible without changing whitespace back and forth in each commit. |
Please fix it |
Please fix! |
Still doesnt work |
Is it not arguable that there are reasons to consider indents on empty lines as non superfluous? If it is arguable at all, then there should be a configuration option for it. Forcing one view to be the solution for everyone in all contexts is extremely frustrating. |
Any chance of prioritizing this? It's a very annoying issue, indeed. |
When I click on a blank line in Visual Studio (Mac) the caret automatically gets a virtual indent from the previous line. In vscode the caret doesn't get any indentation and I have to press tab several times. It infuriates me. Make it behave like in Visual Studio |
Yes, it's awful. When I leave blank space between methods in a class, I want to keep it at that class' indentation, so that it's already right when inserting new code. If you think this space is unnecessary, I disagree, and in fact I think removing it is what's not only unnecessary but also counter-intuitive - unless the user explicitly wants to do it this way. |
It's been 6 years... |
I would also like to see this feature, the auto formatting is basically unusable because of this |
Finally found a decent simple way with this great extension: https://marketplace.visualstudio.com/items?itemName=jemc.vscode-implicit-indent |
Be warned that this extension breaks your undo/redo history. If you undo a bunch of edits then move your caret to an empty line, you'll lose all your redo history. |
Any chance this can be prioritized? Bueller? |
This is the VSCode issue tracking Smart Indent, microsoft/vscode#16998. If the feature is meaningful to you, then be sure to let them know. |
VS Code version: Code 1.19.2 (490ef761b76b3f3b3832eff7a588aac891e5fe80, 2018-01-10T15:55:03.538Z)
C# Extension version: 1.13.1
Steps to reproduce
Make multiple new lines in an indented code block, then
Expected behavior
All lines retain their indentation
Actual behavior
Any lines in the document without code have their indentation removed
I have narrowed this down to this plugin, as this behavior isn't seen in VSCode when extension is disabled. I have tried every combination of white space trimming, etc., with no solution.
See Reddit thread.
The text was updated successfully, but these errors were encountered: