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.
dev build 200811161401 Designer -> Pick some node (mine is a JTable) -> Customize Code -> "custom property" Mine reads "mediaTable.setModel(abc);" where "mediaTable.setModel(" and ");" are colored as protected blocks. There seems to be an off-by-one bug preventing me from deleting the "c" even though it isn't part of the protected block. You can use CTRL+DEL to delete "c" but this is also the source of a second bug: I can use CTRL+DEL to delete protected blocks. Even real ones!
Product Version: NetBeans IDE Dev (Build 200811180201) Java: 1.6.0_10-rc; Java HotSpot(TM) Client VM 11.0-b13 System: Linux version 2.6.27-8-generic running on i386; UTF-8; en_US (nb) Reproducible. Can be done in editor too!! Pressing ctrl+del deletes code in guarded block, eventually resulting in this exception. java.lang.AssertionError: Start offset must be before the end offset. startOffset = 28, endOffset = 27 at org.netbeans.spi.editor.highlighting.support.OffsetsBag.addHighlightImpl(OffsetsBag.java:491) at org.netbeans.spi.editor.highlighting.support.OffsetsBag.addAllHighlightsImpl(OffsetsBag.java:724) at org.netbeans.spi.editor.highlighting.support.OffsetsBag.addAllHighlights(OffsetsBag.java:184) at org.netbeans.modules.editor.lib2.highlighting.CompoundHighlightsContainer.updateCache(CompoundHighlightsContainer.java:302) at org.netbeans.modules.editor.lib2.highlighting.CompoundHighlightsContainer.getHighlights(CompoundHighlightsContainer.java:170) at org.netbeans.editor.HighlightingDrawLayer.processOffset(HighlightingDrawLayer.java:618) at org.netbeans.editor.HighlightingDrawLayer.isActive(HighlightingDrawLayer.java:344) at org.netbeans.editor.DrawEngine.drawArea(DrawEngine.java:884) at org.netbeans.editor.DrawEngine.drawInternal(DrawEngine.java:1168) at org.netbeans.editor.DrawEngine.draw(DrawEngine.java:1074) at org.netbeans.editor.DrawEngineLineView.getModel2ViewRect(DrawEngineLineView.java:413)
Created attachment 73947 [details] full stacktrace
Please don't take away my workaround before you fix the off-by-one bug first :) Otherwise I'll *really* be stuck.
Well, the possibility to delete guarded code is a real problem, IMO. I hope both problems (deleting guarded blocks and problem with edge conditions) will be fixed... As it is present in 6.5 FCS too, it is a good candidate for some patch, I guess... This problem is in mobility development too - reassigning back to editor... Ctrl+Delete and Ctrl+Backspace (delete next/previous word) shortcuts delete text in GB...
Yes, it it reproducible in trunk build strange is that is doesn't happen in parsing api build
The off-by-one seems to be issue 91288. Note there is a workaround for it (quite awkward) - when turning on the custom code section, press space (will replace all the selected code), then move before the space by left cursor key and write your code. This way you leave the space at the last problematic position and the text before it can be edited.
I'll fix it - looks like runAtomic() is used instead of runAtomicAsUser().
Fixed Ctrl+Del/Backspace deletes in guarded blocks - http://hg.netbeans.org/main/rev/1b21e44e55da For off-by-one you can always type a single letter if the space between the blocks is empty. So you need to type the last letter and move in front of it and type the identifier. I understand that it's ugly so I continue working on a fix.
By the way, the main problem isn't typing into the dialog in the first place but rather changing what you typed after the fact. Right now you can't change the code what-so-ever ;) Thanks for scheduling this for M1 though. I'll wait.
Integrated into 'main-golden', will be available in build *200812050201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/1b21e44e55da User: Miloslav Metelka <mmetelka@netbeans.org> Log: #153486 - Off-by-one bug in protected blocks - Ctrl+Del/BackSpace deletes in guarded box fix.
Partially fixed - it's now possible to type between two guarded blocks on a single line (GuardedDocument checks when inserting inside line). However it's not possible to insert a code completion item since the CompletionImpl uses GD.isPosGuarded(pos) which does not reflect whether insert/remove operation is attempted. OTOH the editor.guards expects that GB starts at line's begining so I can't allow begin-line inserts as well. Something has to be changed. Either GD.isPosGuarded() has to have variations or editor.guards must support allowed begin-line inserts. Or we could have two GB types - one multi-line that would not allow begin-line inserts and in-line type which would allow them. Any ideas? http://hg.netbeans.org/main/rev/bccd4b75f3b3
After consulting both form team's requirements and editor.guards module's requirements I will implement the following fix: 1) If the guarded block starts at line's begining it's not possible to insert any text at line's begining except if it contains '\n' as the last character. 2) If GB starts in the middle of a line it's possible to insert any character. 3) When removing a character a new-line before GB should not be removed (since then a GB that previously started at line's begining could start in a middle of line) unless the char right before removal start is also '\n'. This should reflect editor.guards module's behavior that it appends // GEN-BEGIN at the end of first guarded line and so if we would allowed typing at the begining of such GB then a subsequent reopening of the file would cause the typed text to become guarded. If this would not suffice in the longterm we would have to have two GB types - one for editor.guards and another for the special intra-line form folds.
Integrated into 'main-golden', will be available in build *200812091520* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/bccd4b75f3b3 User: Miloslav Metelka <mmetelka@netbeans.org> Log: #153486 - Off-by-one bug in protected blocks - partial fix.
http://hg.netbeans.org/main/rev/8d7dcabd71b5
Integrated into 'main-golden', will be available in build *200812110201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/8d7dcabd71b5 User: Miloslav Metelka <mmetelka@netbeans.org> Log: #153486 - Off-by-one bug in protected blocks - final fix.
I just wanted to point out that this P2 issue has not yet been back-ported to 6.5. Are there plans to do so?
Based on the third bullet in "How to include issues into patch" (http://wiki.netbeans.org/NetBeansPatches), the issue must be fixed and verified by QE or by reporter in the trunk prior integration into the release65_fixes branch. So far the issue is just FIXED/RESOLVED. Sustaining is waiting for a verification in the trunk. If the issue isn't verified by January 13 2009 (the nomination cut-off date), it will be moved to the next patch.
Verified (off-by-one seems to be solved, guarded blocks cannot be deleted using Ctrl+Del/Backspace). There is another bug with undoing, I will file it...
The mentioned undoing bug: #156469
The fix has been ported into the release65_fixes repository. http://hg.netbeans.org/release65_fixes/rev/d4c0f5667f86