New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting code from editor to empty editor produces Exception #4522

Closed
JakubValtar opened this Issue Jun 3, 2016 · 6 comments

Comments

Projects
None yet
2 participants
@JakubValtar
Contributor

JakubValtar commented Jun 3, 2016

Pasting code from one editor to other empty editor produces following exception.

javax.swing.text.BadLocationException: Invalid insert
    at javax.swing.text.GapContent.insertString(GapContent.java:129)
    at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:723)
    at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:707)
    at javax.swing.text.PlainDocument.insertString(PlainDocument.java:130)
    at processing.app.syntax.JEditTextArea.setSelectedText(JEditTextArea.java:1391)
    at processing.app.syntax.JEditTextArea.setSelectedText(JEditTextArea.java:1369)
    at processing.app.syntax.JEditTextArea.paste(JEditTextArea.java:1798)
    at processing.app.ui.Editor$PasteAction.actionPerformed(Editor.java:1331)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:356)
    at javax.swing.plaf.basic.BasicMenuItemUI$Actions.actionPerformed(BasicMenuItemUI.java:802)
    at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1663)
    at javax.swing.JComponent.processKeyBinding(JComponent.java:2882)
    at javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:699)
    at javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:706)
    at javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:706)
    at javax.swing.JMenuBar.processKeyBinding(JMenuBar.java:677)
    at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:307)
    at javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:293)
    at javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2974)
    at javax.swing.JComponent.processKeyBindings(JComponent.java:2966)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2845)
    at processing.app.syntax.JEditTextArea.processKeyEvent(JEditTextArea.java:1868)
    at processing.mode.java.pdex.JavaTextArea.processKeyEvent(JavaTextArea.java:176)
    at java.awt.Component.processEvent(Component.java:6310)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
    at java.awt.Component.dispatchEventImpl(Component.java:4760)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Exception in thread "AWT-EventQueue-0" java.lang.InternalError: Cannot replace selection
    at processing.app.syntax.JEditTextArea.setSelectedText(JEditTextArea.java:1395)
    at processing.app.syntax.JEditTextArea.setSelectedText(JEditTextArea.java:1369)
    at processing.app.syntax.JEditTextArea.paste(JEditTextArea.java:1798)
    at processing.app.ui.Editor$PasteAction.actionPerformed(Editor.java:1331)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:356)
    at javax.swing.plaf.basic.BasicMenuItemUI$Actions.actionPerformed(BasicMenuItemUI.java:802)
    at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1663)
    at javax.swing.JComponent.processKeyBinding(JComponent.java:2882)
    at javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:699)
    at javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:706)
    at javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:706)
    at javax.swing.JMenuBar.processKeyBinding(JMenuBar.java:677)
    at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:307)
    at javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:293)
    at javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2974)
    at javax.swing.JComponent.processKeyBindings(JComponent.java:2966)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2845)
    at processing.app.syntax.JEditTextArea.processKeyEvent(JEditTextArea.java:1868)
    at processing.mode.java.pdex.JavaTextArea.processKeyEvent(JavaTextArea.java:176)
    at java.awt.Component.processEvent(Component.java:6310)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
    at java.awt.Component.dispatchEventImpl(Component.java:4760)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

@JakubValtar JakubValtar changed the title from Pasting code between editors produces Exception to Pasting code from editor to empty editor produces Exception Jun 3, 2016

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Jun 7, 2016

Member

Is this something you're planning to take a look at anytime soon or do I need to dig into it?

Is it a regression from the recent editor changes?

Member

benfry commented Jun 7, 2016

Is this something you're planning to take a look at anytime soon or do I need to dig into it?

Is it a regression from the recent editor changes?

@JakubValtar

This comment has been minimized.

Show comment
Hide comment
@JakubValtar

JakubValtar Jun 9, 2016

Contributor

@benfry I suspect it might be caused by #4310. I won't have much time for this for another two weeks.

Contributor

JakubValtar commented Jun 9, 2016

@benfry I suspect it might be caused by #4310. I won't have much time for this for another two weeks.

@JakubValtar

This comment has been minimized.

Show comment
Hide comment
@JakubValtar

JakubValtar Aug 1, 2016

Contributor

@benfry This and other weirdness seems to be caused by all Editors sharing a single TokenMarker instance (which lives in Mode). If you switch Editors fast enough, TokenMarker returns some values intended for the other Editor. It would probably take a few hours to figure out what is happening.

Contributor

JakubValtar commented Aug 1, 2016

@benfry This and other weirdness seems to be caused by all Editors sharing a single TokenMarker instance (which lives in Mode). If you switch Editors fast enough, TokenMarker returns some values intended for the other Editor. It would probably take a few hours to figure out what is happening.

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Aug 1, 2016

Member

Ah, I see it... It's the shared lastOffset and lastKeyword variables. I'll fix.

Member

benfry commented Aug 1, 2016

Ah, I see it... It's the shared lastOffset and lastKeyword variables. I'll fix.

@JakubValtar

This comment has been minimized.

Show comment
Hide comment
@JakubValtar

JakubValtar Aug 1, 2016

Contributor

I don't think these two are causing this problem (still better to not have them though). I think it's one of the fields of TokenMarker itself, there is a lot hidden somewhere in the middle.

Contributor

JakubValtar commented Aug 1, 2016

I don't think these two are causing this problem (still better to not have them though). I think it's one of the fields of TokenMarker itself, there is a lot hidden somewhere in the middle.

@benfry benfry closed this in 62f5089 Aug 1, 2016

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Aug 1, 2016

Member

Ok, though those two variables are gonna be a problem and not thread-safe, so I've modified that. (Re-opening this since it auto-closed...)

Member

benfry commented Aug 1, 2016

Ok, though those two variables are gonna be a problem and not thread-safe, so I've modified that. (Re-opening this since it auto-closed...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment