Skip to content
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

Wrong text insert in CodeArea #475

Closed
ErnstMosinski opened this issue Mar 30, 2017 · 3 comments
Closed

Wrong text insert in CodeArea #475

ErnstMosinski opened this issue Mar 30, 2017 · 3 comments

Comments

@ErnstMosinski
Copy link

I just tested the CodeArea and downloaded the richtextfx-0.7-M4 JARs.
If you enter text in the CodeArea the cursor is not moved and all characters are enter at the current position.
This looks like you type in text in reverse.
This can easily be reproduce by running the JavaKeywords example from the richtextfx-demos-fat-0.7-M4.jar file.
Is it possible to workaround this by setting some properties, or is it just a bug who needs to be fixed?

@alt-grr
Copy link

alt-grr commented Mar 30, 2017

Duplicate of #472, already fixed.

@JordanMartinez
Copy link
Contributor

JordanMartinez commented Mar 31, 2017

It is possible to fix this regression in the 0.7-M4 release by overriding the replace method like so:

public void replace(int from, int to, StyledDocument<PS, SEG, S> document) {
    if (from == to && document.length() == 0) {
        return; // ignore changes that do nothing. Or TextChange throws IllegalArgumentException
    }
    super.replace(from, to, document);
    int newCaretPos = getCaretPosition() + document.length();
    selectRange(newCaretPos, newCaretPos);
}

@ErnstMosinski
Copy link
Author

Thanks for this information!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants