This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I have the Strip Whitespace plugin installed so I see the white space in my code. Every time I hit enter to add another line it adds white space up to where the cursor is placed. I can then toggle the Strip white space plugin to do its work, but I should not have to do that.
Can you attach some screenshots? I cannot reproduce it. Which build do you use?
Well, it sounds like a Strip Whitespace plugin problem. I'm not sure who the maintainers are, but hopefully somebody will pick this up.
Created attachment 50522 [details] Before enter hit three times
Created attachment 50523 [details] After enter hit three times
Shot1 is before any changes. Shot2 is just after I hit enter at the end of line 32 (//TODO code ....) three times.
The real problem is that the editor inserts useless trailing whitespace as you edit. This has long been complained about.
I see, thanks for the screenshots. I'm not sure if we want to fix this. The expected behavior is that after pressing enter the new line is correctly indented. That's why the editor inserts spaces there. IMO Swing based editors are bound to do that, because caret positioning is based on document offsets (not visual coordinates), so there has to be whitespace characters present in the document.
But the editor could nonetheless remove trailing whitespace from an edited line after moving away from it (or saving). Thus you would have ---%<--- #1 void m() {<<CARET>> } ---%<--- ENTER => #2 void m() { ____<<CARET>> } ---%<--- some text => #3 void m() { ____doSomething();<<CARET>> } ---%<--- ENTER => #4 void m() { ____doSomething(); ____<<CARET>> } ---%<--- ENTER => #5 void m() { ____doSomething(); ____<<CARET>> } ---%<--- some text => #6 void m() { ____doSomething(); ____doSomethingElse();<<CARET>> } ---%<--- ENTER => #7 void m() { ____doSomething(); ____doSomethingElse(); ____<<CARET>> } ---%<--- Save => #8 void m() { ____doSomething(); ____doSomethingElse(); <<CARET>> } ---%<--- which would work fine with a Swing editor yet still prevent the introduction of unwanted trailing spaces.
Yeah, I see what you mean, but I don't think it would be that easy. For example what if in #4 you don't press enter, but simply use up/down arrow or any other means of navigation to move away from the line? Should the whitspace [a] stay or [b] be removed. a. If it stays then you will eventually end up with trailing whitespace in your files anyway. So, the feature does not work properly and we will have to battle this type of defects forever. b. Removing the whitespace means that simple navigation modifies the document, which IMO is very unexpected. I'm really sorry, but to me this looks like too much hassle for nothing. If you guys have strong objection please reopen the defect, but unless somebody volunteers to implement this and more importantly socialize it among people this is going to be on the back burner anyway.
(b), though only if the line was just edited anyway. Alternately: (a) but remove it upon save. The ideal outcome is that no line which has been edited is left with trailing whitespace. (Removing whitespace from unedited lines is potentially rude to a VCS so this is probably best avoided, or at least made optional.) This isn't a DEFECT - the editor is working as designed - but it is certainly not "nothing"; people have been complaining for a long time that NB's editor adds trailing whitespaces to documents, hence the various contributed modules to detect and remove it. Probably a new module is needed to implement the suggested behavior; I don't know if there is some kind of pre-save hook in the NB editor, but that would be needed.
See issue #13063, with 17 votes and at least 5 duplicates.
Ok, ok, I can see that there is enough people who care about this and we should not just simply throw it into a rubbish bin. Will everybody be fine if I mark this as duplicate of #13063?
Up to reporter I guess...
*** This issue has been marked as a duplicate of 13063 ***