You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling CodeArea.replaceText() should replace the contents of the CodeArea without throwing any exception.
Actual Behavior
When the CodeArea contains multiple lines, calling CodeArea.replaceText() triggers an exception, show below:
Button pressed
Button pressed
Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Visible paragraphs' last index is [-1] but visibleParIndex was [0]
at org.fxmisc.richtext.GenericStyledArea.visibleParToAllParIndex(GenericStyledArea.java:982)
at org.fxmisc.richtext.ViewActions.firstVisibleParToAllParIndex(ViewActions.java:284)
at org.fxmisc.richtext.LineNumberFactory.insertParagraphCheck(LineNumberFactory.java:172)
at org.fxmisc.richtext.LineNumberFactory.lambda$new$2(LineNumberFactory.java:92)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:447)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:446)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:831)
Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Visible paragraphs' last index is [-1] but visibleParIndex was [0]
at org.fxmisc.richtext.GenericStyledArea.visibleParToAllParIndex(GenericStyledArea.java:982)
at org.fxmisc.richtext.ViewActions.firstVisibleParToAllParIndex(ViewActions.java:284)
at org.fxmisc.richtext.LineNumberFactory.deleteParagraphCheck(LineNumberFactory.java:148)
at org.fxmisc.richtext.LineNumberFactory.lambda$new$1(LineNumberFactory.java:91)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:447)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:446)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:831)
Reproducible Demo
Run this, then press the button twice.
Use the following template to get started.
publicclassAppextendsApplication {
CodeAreacodeArea;
Buttonbutton;
publicstaticvoidmain(String[] args) {
launch();
}
@Overridepublicvoidstart(StageprimaryStage) throwsException {
codeArea = newCodeArea();
codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
codeArea.setWrapText(false);
button = newButton("Press me Twice");
button.setOnAction(actionEvent -> {
actionEvent.consume();
System.out.println("Button pressed");
codeArea.clear();
// Doesn't really matter what is inside codeArea text,// As long as it span multiple lines, the exception is throwncodeArea.appendText("Lorem ipsum\n");
// If you remove the \n from above it won't throw an exception anymorecodeArea.replaceText(String.valueOf(Math.random()));
});
Parentroot = newStackPane(codeArea, button);
primaryStage.setScene(newScene(root));
primaryStage.show();
}
}
Environment info:
RichTextFX Version: 0.10.6 from Maven
Operating System: Windows 21H1 and ArchLinux
Java version: 16.0.1 (Microsoft and ArchLinux's OpenJDK builds)
As this bug is reproducible on multiple OSes and JDK builds, I don't think this is platform dependent.
The text was updated successfully, but these errors were encountered:
Expected Behavior
Calling CodeArea.replaceText() should replace the contents of the CodeArea without throwing any exception.
Actual Behavior
When the CodeArea contains multiple lines, calling CodeArea.replaceText() triggers an exception, show below:
Reproducible Demo
Run this, then press the button twice.
Use the following template to get started.
Environment info:
As this bug is reproducible on multiple OSes and JDK builds, I don't think this is platform dependent.
The text was updated successfully, but these errors were encountered: