nordfalk / jsyntaxpane

An updated version of code.google.com/p/jsyntaxpane r096 branch
36 stars 22 forks source link

Please test with Java 9, there appear to be issues with cast of DocumentEvent #198

Closed jbfaden closed 7 years ago

jbfaden commented 7 years ago

Running JSyntaxPane under Java 9:

java.lang.ClassCastException: java.desktop/javax.swing.text.AbstractDocument$DefaultDocumentEventUndoableWrapper cannot be cast to java.desktop/javax.swing.text.AbstractDocument$DefaultDocumentEvent at jsyntaxpane.CompoundUndoManager.undoableEditHappened(CompoundUndoManager.java:61) at java.desktop/javax.swing.text.AbstractDocument.fireUndoableEditUpdate(AbstractDocument.java:293) at java.desktop/javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:761) at java.desktop/javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:716) at java.desktop/javax.swing.text.PlainDocument.insertString(PlainDocument.java:131) at jsyntaxpane.SyntaxTester.loadFile(SyntaxTester.java:229) at jsyntaxpane.SyntaxTester.(SyntaxTester.java:42) at jsyntaxpane.SyntaxTester$4.run(SyntaxTester.java:246) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764) at java.desktop/java.awt.EventQueue.access$500(EventQueue.java:97) at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:717) at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:711) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:89) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:734) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:199) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

nordfalk commented 7 years ago

Thanks for your report. Ive fixed this in https://github.com/nordfalk/jsyntaxpane/commit/5fc75594f8bc4df6e8f7096d4a440490b768fd46 and released version 1.1.5

The fix effectively disables compound undo - so each character edit is a seperate undo, which is uncool but it seems Java 9 hides the line edited and I can't see how to fix that

nordfalk commented 7 years ago

@Sciss , you might want to do the same fix

jbfaden commented 7 years ago

We put in a fix similar to this in our branch, actually I allow the EditManager to be set externally, and then put in the example character-by-character undo I found on the web. Since the syntax is available, it seems we could have a very precise UndoManager which would compound nodes of the syntax tree, and I'll let you know if we have success with this.

nordfalk commented 7 years ago

Ok, seems I could have saved some time making my fix. Please make a pull request if you think your fix is better

Den 20. sep. 2017 1.44 PM skrev "Jeremy Faden" notifications@github.com:

We put in a fix similar to this in our branch, actually I allow the EditManager to be set externally, and then put in the example character-by-character undo I found on the web. Since the syntax is available, it seems we could have a very precise UndoManager which would compound nodes of the syntax tree, and I'll let you know if we have success with this.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/nordfalk/jsyntaxpane/issues/198#issuecomment-330826751, or mute the thread https://github.com/notifications/unsubscribe-auth/ABFx6BpOpojtH2wdkXYeDSSjerBGs4qyks5skPqbgaJpZM4PXypI .

jbfaden commented 7 years ago

Thanks for looking into this, and I apologize for not updating this issue. It was a bit rushed, trying to make a release. I'll update this ticket if I find a better solution.