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
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@editor
Depends on:
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:

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(
	at org.netbeans.editor.DocumentContent.createPosition(
	at javax.swing.text.AbstractDocument.createPosition(
	at org.netbeans.modules.editor.indent.TaskHandler.setCaretOffset(
	at org.netbeans.modules.editor.indent.IndentImpl.reindent(
	at org.netbeans.modules.editor.indent.FormatterImpl.indentLine(
Caused: java.lang.IllegalStateException
	at org.netbeans.modules.editor.indent.FormatterImpl.indentLine(
	at org.netbeans.modules.editor.indent.FormatterImpl.indentNewLine(
	at org.netbeans.editor.BaseKit$SplitLineAction.actionPerformed(
	at org.netbeans.editor.BaseAction.actionPerformed(
	at javax.swing.SwingUtilities.notifyAction(
	at javax.swing.JComponent.processKeyBinding(
	at javax.swing.JComponent.processKeyBindings(
	at javax.swing.JComponent.processKeyEvent(
	at java.awt.Component.processEvent(
	at java.awt.Container.processEvent(
	at java.awt.Component.dispatchEventImpl(
	at java.awt.Container.dispatchEventImpl(
	at java.awt.Component.dispatchEvent(
	at java.awt.KeyboardFocusManager.redispatchEvent(
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(
	at java.awt.Component.dispatchEventImpl(
	at java.awt.Container.dispatchEventImpl(
	at java.awt.Window.dispatchEventImpl(
	at java.awt.Component.dispatchEvent(
[catch] at java.awt.EventQueue.dispatchEvent(
	at java.awt.EventDispatchThread.pumpOneEventForFilters(
	at java.awt.EventDispatchThread.pumpEventsForFilter(
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(
	at java.awt.EventDispatchThread.pumpEvents(
	at java.awt.EventDispatchThread.pumpEvents(
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