EditorTextField and selection

Hi.

I'm creating an EditorTextField using the following code:

Set<EditorCustomization> features = new HashSet<EditorCustomization>(); features.add(SoftWrapsEditorCustomization.ENABLED); features.add(AdditionalPageAtBottomEditorCustomization.DISABLED); Project defaultProject = ProjectManager.getInstance().getDefaultProject(); EditorTextFieldProvider service = ServiceManager.getService(defaultProject, EditorTextFieldProvider.class); return service.getEditorField(FileTypes.PLAIN_TEXT.getLanguage(), defaultProject, features);


I'm adding such field to a DialogWrapper and showing it. The problem is, when I double click on a word on a single line of text, it normally selects all the text. If I type a few more lines, sometimes double clicking on words select the word, and sometimes just half the text, randomly. And after I start removing text and I have only one line left, if I try to select a word sgain using double click, I get the following exception:

java.lang.IndexOutOfBoundsException: Wrong offset: 20; count:20      at com.intellij.openapi.editor.impl.CharArray.charAt(CharArray.java:420)      at com.intellij.openapi.util.text.StringUtil.indexOf(StringUtil.java:1629)      at com.intellij.openapi.util.text.StringUtil.contains(StringUtil.java:1607)      at com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase.expandToWholeLine(ExtendWordSelectionHandlerBase.java:81)      at com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase.select(ExtendWordSelectionHandlerBase.java:45)      at com.intellij.codeInsight.editorActions.wordSelection.AbstractWordSelectioner.select(AbstractWordSelectioner.java:41)      at com.intellij.codeInsight.editorActions.SelectWordUtil.b(SelectWordUtil.java:222)      at com.intellij.codeInsight.editorActions.SelectWordUtil.a(SelectWordUtil.java:197)      at com.intellij.codeInsight.editorActions.SelectWordUtil.processRanges(SelectWordUtil.java:165)      at com.intellij.codeInsight.editorActions.SelectWordHandler.a(SelectWordHandler.java:143)      at com.intellij.codeInsight.editorActions.SelectWordHandler.execute(SelectWordHandler.java:80)      at com.intellij.openapi.editor.actions.SelectWordAtCaretAction$Handler.execute(SelectWordAtCaretAction.java:108)      at com.intellij.openapi.editor.impl.SelectionModelImpl.selectWordAtCaret(SelectionModelImpl.java:819)      at com.intellij.openapi.editor.impl.EditorImpl.a(EditorImpl.java:5623)      at com.intellij.openapi.editor.impl.EditorImpl.access$10600(EditorImpl.java:137)      at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.f(EditorImpl.java:5595)      at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.access$9600(EditorImpl.java:5315)      at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter$1.run(EditorImpl.java:5380)      at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:124)      at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.a(EditorImpl.java:5385)      at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.mousePressed(EditorImpl.java:5321)      at java.awt.Component.processMouseEvent(Component.java:6411)      at javax.swing.JComponent.processMouseEvent(JComponent.java:3275)      at java.awt.Component.processEvent(Component.java:6179)      at java.awt.Container.processEvent(Container.java:2083)      at java.awt.Component.dispatchEventImpl(Component.java:4776)      at java.awt.Container.dispatchEventImpl(Container.java:2141)      at java.awt.Component.dispatchEvent(Component.java:4604)      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4619)      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4277)      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4210)      at java.awt.Container.dispatchEventImpl(Container.java:2127)      at java.awt.Window.dispatchEventImpl(Window.java:2489)      at java.awt.Component.dispatchEvent(Component.java:4604)      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:717)      at java.awt.EventQueue.access$400(EventQueue.java:82)      at java.awt.EventQueue$2.run(EventQueue.java:676)      at java.awt.EventQueue$2.run(EventQueue.java:674)      at java.security.AccessController.doPrivileged(Native Method)      at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)      at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:97)      at java.awt.EventQueue$3.run(EventQueue.java:690)      at java.awt.EventQueue$3.run(EventQueue.java:688)      at java.security.AccessController.doPrivileged(Native Method)      at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)      at java.awt.EventQueue.dispatchEvent(EventQueue.java:687)      at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:696)      at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:520)      at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:205)      at java.awt.Dialog$1.run(Dialog.java:1049)      at java.awt.Dialog$3.run(Dialog.java:1101)      at java.security.AccessController.doPrivileged(Native Method)      at java.awt.Dialog.show(Dialog.java:1099)      at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:786)      at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:462)      at com.intellij.openapi.ui.DialogWrapper.showAndGetOk(DialogWrapper.java:1543)      at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1511)
        ...


Is there a way of making the field work consistently? I don't have any kind of listener on the field or interact with it in any way (except calling setText/getText). A normal JTextArea doesn't present this problems (but there is no undo support, that I need). Also, I think this field is being used in the VCS commit support, and I don't see that behavior there.

I'm using Intellij IDEA 13.0.1

2 comments
Comment actions Permalink

This exception is a bug in IntelliJ IDEA. Please report it to YouTrack; there's nothing you can do in your plugin to fix it.

0
Comment actions Permalink

Thanks, will do.

0

Please sign in to leave a comment.