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.

Bug 117968 - White space added when enter pressed
Summary: White space added when enter pressed
Status: RESOLVED DUPLICATE of bug 13063
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: PC All
: P4 blocker (vote)
Assignee: issues@editor
Depends on:
Reported: 2007-10-05 22:17 UTC by darrinps
Modified: 2007-11-05 13:44 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:

Before enter hit three times (20.64 KB, application/octet-stream)
2007-10-09 18:28 UTC, darrinps
After enter hit three times (13.12 KB, application/octet-stream)
2007-10-09 18:28 UTC, darrinps

Note You need to log in before you can comment on or make changes to this bug.
Description darrinps 2007-10-05 22:17:55 UTC
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.
Comment 1 Jiri Prox 2007-10-08 08:28:11 UTC
Can you attach some screenshots? I cannot reproduce it. Which build do you use?
Comment 2 Vitezslav Stejskal 2007-10-08 11:02:49 UTC
Well, it sounds like a Strip Whitespace plugin problem. I'm not sure who the maintainers are, but hopefully somebody
will pick this up.
Comment 3 darrinps 2007-10-09 18:28:12 UTC
Created attachment 50522 [details]
Before enter hit three times
Comment 4 darrinps 2007-10-09 18:28:45 UTC
Created attachment 50523 [details]
After enter hit three times
Comment 5 darrinps 2007-10-09 18:29:22 UTC
Shot1 is before any changes.

Shot2 is just after I hit enter at the end of line 32 (//TODO code ....) three times.
Comment 6 Jesse Glick 2007-10-10 02:11:24 UTC
The real problem is that the editor inserts useless trailing whitespace as you edit. This has long been complained about.
Comment 7 Vitezslav Stejskal 2007-10-10 11:03:51 UTC
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.
Comment 8 Jesse Glick 2007-10-10 13:49:05 UTC
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() {
---%<--- some text => #3
void m() {
---%<--- ENTER => #4
void m() {
---%<--- ENTER => #5
void m() {

---%<--- some text => #6
void m() {

---%<--- ENTER => #7
void m() {

---%<--- Save => #8
void m() {


which would work fine with a Swing editor yet still prevent the introduction of unwanted trailing spaces.
Comment 9 Vitezslav Stejskal 2007-10-10 15:12:00 UTC
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.
Comment 10 Jesse Glick 2007-10-10 15:26:35 UTC
(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.
Comment 11 Jesse Glick 2007-10-12 16:02:15 UTC
See issue #13063, with 17 votes and at least 5 duplicates.
Comment 12 Vitezslav Stejskal 2007-10-15 14:57:00 UTC
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?
Comment 13 Jesse Glick 2007-10-15 22:48:31 UTC
Up to reporter I guess...
Comment 14 Vitezslav Stejskal 2007-10-17 11:43:41 UTC

*** This issue has been marked as a duplicate of 13063 ***