Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Really, why is this not the default setting?
IIRC it was off by default for two reasons:
a) it was overzealous about removing whitespace from existing code, which caused a lot of noise on existing projects
b) the "virtual space" support - which allows the caret to be placed on empty lines as if there were whitespace to the level computed by the indenter - was buggy
TBH, I don't think stripping whitespace is the solution to the problem. It's hard to make it reliably strip whitespace only from new code and not existing code. Instead, we need to be smarter about not inserting it.
We should look at what other editors do, but a good start might be:
a) make sure the virtual space support is usable, currently it's still impossible to correct it manually when the indenter position is wrong. Maybe backspace and left movement could be used to edit the virtual whitespace?
b) fix the C# smart indenter. If the previous line doesn't match what it computed, it should adjust its value for the current line by the same amount.
c) when adding a new line, don't add indenter whitespace, instead just move the caret directly to the "virtual" position
d) don't add indenter whitespace in generated blank lines (e.g. event handlers, templates)
e) remove leading whitespace from a line when all the other text on that line is deleted, but keep the caret in the virtual position
Also, an option to highlight trailing whitespace and inconsistent newlines like git does would be nice.
Souldn't be a default setting because of a). And trailing whitespace removal can lead to semantic changes (verbatim strings for example).
Virtual white spaces shouldn't be editable - the indent position can be correctly calculated - at least in the newresolver branch.
btw. many people want blank lines indented - it's for example a policy in nrefactory and I think it's more or less the "default".
I think it's premature to call this "fixed" - even if we don't change the default, our handling of leading/trailing whitespace is subpar.
I stand by my point that removal is not the solution - if anything, your point that it can cause semantic changes reinforces this.
The policy setting should be "Do not indent blank lines", and MD should handle this by not inserting the indentation, as I described.
The original thing is 'fixed' that there may be improvement of whitespace handling is different. Removal of whitespace is something some users want - like the one who opened this bug.
I think that people know what they're doing can handle that. I don't have exact numbers here, but people WANT the indentation even on blank lines. It's not a bug or wrong feature. We need to allow that.
We could have a mode where indent doesn't insert blank lines and whitespaces are not truncated and indenting is just done virtually, I'll need to think about that.
The question is should we keep "truncate whitespaces then" ?
Ok I implemented a 'virtual' indent mode - that's more or less what vs.net does.
I think monodevelop input works best in conjunction with the on the fly format - but the "input text" feature needs to be improved.
I need more use cases - but I think the virtual indent mode goes in the right direction.