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 commita7c8b0b535) (cherry picked from commit48410e5865)
This commit is contained in:
@@ -4764,6 +4764,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()) {
|
||||
@@ -4771,6 +4774,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;
|
||||
@@ -4846,6 +4858,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