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 120011 - javax.swing.text.BadLocationException during Split Line Action
Summary: javax.swing.text.BadLocationException during Split Line Action
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@editor
URL:
Keywords: SIMPLEFIX
Depends on:
Blocks:
 
Reported: 2007-10-25 11:48 UTC by jsvec
Modified: 2008-02-26 16:58 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Fix for this issue, also fixes erornous behaviour when selection was started above the current caret location (1.30 KB, patch)
2007-11-27 10:17 UTC, jsvec
Details | Diff
Modified patch for the new mercurial repository structure. (1.20 KB, patch)
2008-02-22 12:12 UTC, jsvec
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jsvec 2007-10-25 11:48:09 UTC
To reproduce this problem:

1) Open file editor (I tried this with empty file, XML file and also Java source file)
2) the file must contain at least 2 characters
3) select all "ctrl+a"
4) press "ctrl+enter" (Split Line Action) ... and the editor throws ...

javax.swing.text.BadLocationException: Invalid offset=3, docLength=0
	at org.netbeans.editor.DocumentContent.checkOffset(DocumentContent.java:325)
	at org.netbeans.editor.DocumentContent.createPosition(DocumentContent.java:116)
	at javax.swing.text.AbstractDocument.createPosition(AbstractDocument.java:816)
	at org.netbeans.modules.editor.indent.TaskHandler.setCaretOffset(TaskHandler.java:120)
	at org.netbeans.modules.editor.indent.IndentImpl.reindent(IndentImpl.java:193)
	at org.netbeans.modules.editor.indent.FormatterImpl.indentLine(FormatterImpl.java:138)
Caused: java.lang.IllegalStateException
	at org.netbeans.modules.editor.indent.FormatterImpl.indentLine(FormatterImpl.java:142)
	at org.netbeans.modules.editor.indent.FormatterImpl.indentNewLine(FormatterImpl.java:133)
	at org.netbeans.editor.BaseKit$SplitLineAction.actionPerformed(BaseKit.java:1201)
	at org.netbeans.editor.BaseAction.actionPerformed(BaseAction.java:290)
	at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1636)
	at javax.swing.JComponent.processKeyBinding(JComponent.java:2844)
	at javax.swing.JComponent.processKeyBindings(JComponent.java:2879)
	at javax.swing.JComponent.processKeyEvent(JComponent.java:2807)
	at java.awt.Component.processEvent(Component.java:5815)
	at java.awt.Container.processEvent(Container.java:2058)
	at java.awt.Component.dispatchEventImpl(Component.java:4410)
	at java.awt.Container.dispatchEventImpl(Container.java:2116)
	at java.awt.Component.dispatchEvent(Component.java:4240)
	at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:693)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:958)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:830)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:657)
	at java.awt.Component.dispatchEventImpl(Component.java:4282)
	at java.awt.Container.dispatchEventImpl(Container.java:2116)
	at java.awt.Window.dispatchEventImpl(Window.java:2429)
	at java.awt.Component.dispatchEvent(Component.java:4240)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Comment 1 Vitezslav Stejskal 2007-10-26 12:13:50 UTC
Yeah, it seems to crash always when there is a selection.
Comment 2 jsvec 2007-11-27 10:17:44 UTC
Created attachment 53531 [details]
Fix for this issue, also fixes erornous behaviour when selection was started above the current caret location
Comment 3 jsvec 2008-02-22 12:12:49 UTC
Created attachment 57058 [details]
Modified patch for the new mercurial repository structure.
Comment 4 jsvec 2008-02-22 12:14:59 UTC
Modified version and target milestone, because the bug is still not fixed.
Comment 5 Vitezslav Stejskal 2008-02-22 16:50:22 UTC
Oh, thanks for the patch. Please do not change the version field. If the defect was discovered in 6.0 then unless marked
as fixed with target milestone referring to 6.1 we automatically assume the defect also exists in 6.1. If you changed
the version as you did, it would appear that the defect was introduced in 6.1 and that maybe the action worked in 6.0.
Anyway, thanks for the patch, I'll have a look and apply it.
Comment 6 Vitezslav Stejskal 2008-02-26 16:58:27 UTC
Patch applied, I'm sorry that it took so long.

changeset f6e5d197a4aa in main
details: http://hg.netbeans.org/main?cmd=changeset;node=f6e5d197a4aa