mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-1995: Last character issue with korean
Fix for JTextComponent
(cherry picked from commit a7c8b0b535)
This commit is contained in:
committed by
alexey.ushakov@jetbrains.com
parent
3940f61329
commit
c6b8ff0533
@@ -4781,6 +4781,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
|
||||
AttributedCharacterIterator text = e.getText();
|
||||
int composedTextIndex;
|
||||
|
||||
boolean isCaretMoved = false;
|
||||
int caretPositionToRestore = 0;
|
||||
|
||||
// old composed text deletion
|
||||
Document doc = getDocument();
|
||||
if (composedTextExists()) {
|
||||
@@ -4788,6 +4791,15 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
|
||||
doc.remove(composedTextStart.getOffset(),
|
||||
composedTextEnd.getOffset() -
|
||||
composedTextStart.getOffset());
|
||||
isCaretMoved = caret.getDot() != composedTextStart.getOffset();
|
||||
if (isCaretMoved) {
|
||||
caretPositionToRestore = caret.getDot();
|
||||
// if caret set furter in the doc, we should add commitCount
|
||||
if (caretPositionToRestore > composedTextStart.getOffset()) {
|
||||
caretPositionToRestore += commitCount;
|
||||
}
|
||||
caret.setDot(composedTextStart.getOffset());
|
||||
}
|
||||
} catch (BadLocationException ble) {}
|
||||
composedTextStart = composedTextEnd = null;
|
||||
composedTextAttribute = null;
|
||||
@@ -4863,6 +4875,10 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
|
||||
latestCommittedTextEnd = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (isCaretMoved) {
|
||||
caret.setDot(caretPositionToRestore);
|
||||
}
|
||||
}
|
||||
|
||||
private void createComposedTextAttribute(int composedIndex,
|
||||
|
||||
Reference in New Issue
Block a user