-
Notifications
You must be signed in to change notification settings - Fork 236
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
[0.9.2] Replace selected text with pasted text causes exception #788
Comments
@xweichen thanks for reporting. Observations I've made so far is that the exception only happens under the following conditions:
|
The following code produces the reported exception:
or
|
…on (issues FXMisc#777 and FXMisc#788) (borrowed code from ReactFX, which uses same license as RichTextFX)
This is still a problem in 0.10.3 import org.fxmisc.richtext.CodeArea;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class FooBar
{
public static void main(String[] args)
{
Application.launch(MainWindow.class);
}
public static class MainWindow extends Application
{
@Override
public void start(final Stage primaryStage)
{
final CodeArea area = new CodeArea();
final Button button = new Button("Throw exception");
button.setOnAction(e ->
{
String test = "a\n";
area.replaceText( test );
area.appendText( test +"d" );
area.replaceText( test +"d" );
});
final BorderPane root = new BorderPane(area);
root.setBottom(button);
final Scene scene = new Scene(root, 600, 400);
primaryStage.setScene(scene);
primaryStage.show();
}
}
} If you press the "Throw exception" button, it performs the same steps as outlined by @Jugen here and it throws the same exception. I can also reproduce by hand |
I've checked into this with JRE 8 and JRE 11 using your code with 0.10.3 and it unfortunately doesn't throw the exception ? Could you double check that your classpath is indeed using the latest RichTextFX jar and if so then could you please provide additional information that might help. |
My apologies, I guess my IDE didn't pickup the change in the |
Replace selected text with pasted text causes exception aslo happen in 0.9.2
test steps:
1、input a\nb\nc
2、ctrl+a select all and ctrl+c to copy all
3、select from end to start,select c\nb and ctrl+v
4、ctrl+a select all and ctrl+v
exception like this:
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: [1, 0) is not a valid range within [0, 3)
at org.reactfx.util.Lists.checkRange(Lists.java:128)
at org.reactfx.util.Lists.checkRange(Lists.java:123)
at org.reactfx.util.FingerTree$Branch$1.subList(FingerTree.java:489)
at org.reactfx.collection.MaterializedListModification.lambda$0(MaterializedListModification.java:30)
at org.reactfx.util.Tuple2.map(Tuple2.java:31)
at org.reactfx.collection.MaterializedListModification.trim(MaterializedListModification.java:23)
at org.fxmisc.richtext.model.GenericEditableStyledDocumentBase$ParagraphList.lambda$observeInputs$0(GenericEditableStyledDocumentBase.java:46)
at org.reactfx.util.NonAccumulativeStreamNotifications.lambda$0(NotificationAccumulator.java:134)
The text was updated successfully, but these errors were encountered: