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:
@@ -4780,6 +4780,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()) {
|
||||
@@ -4787,6 +4790,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;
|
||||
@@ -4862,6 +4874,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