void (@NotNull InputMethodEvent e) { if (myNeedToSelectPreviousChar && SystemInfo.isMac && (Registry.is("ide.mac.pressAndHold.brute.workaround") || Registry.is("ide.mac.pressAndHold.workaround") && (e.getCommittedCharacterCount() > 0 || e.getCaret() == null))) { // This is required to support input of accented characters using press-and-hold method (http://support.apple.com/kb/PH11264). // JDK currently properly supports this functionality only for TextComponent/JTextComponent descendants. // For our editor component we need this workaround. // After https://bugs.openjdk.org/browse/JDK-8074882 is fixed, this workaround should be replaced with a proper solution. myNeedToSelectPreviousChar = false; getCaretModel().runForEachCaret(new CaretAction() { @Override public void perform(Caret caret) { int caretOffset = caret.getOffset(); if (caretOffset > 0) { caret.setSelection(caretOffset - 1, caretOffset); } } }); } int commitCount = e.getCommittedCharacterCount(); AttributedCharacterIterator text = e.getText(); // old composed text deletion final Document doc = getDocument(); if (composedText != null) { if (!isViewer() && doc.isWritable()) { runUndoTransparent(new Runnable() { @Override public void run() { int docLength = doc.getTextLength(); ProperTextRange range = composedTextRange.intersection(new TextRange(0, docLength)); if (range != null) { doc.deleteString(range.getStartOffset(), range.getEndOffset()); } } }); } composedText = null; } if (text != null) { text.first(); // committed text insertion if (commitCount > 0) { //noinspection ForLoopThatDoesntUseLoopVariable for (char c = text.current(); commitCount > 0; c = text.next(), commitCount--) { if (c >= 0x20 && c != 0x7F) { // Hack just like in javax.swing.text.DefaultEditorKit.DefaultKeyTypedAction processKeyTyped(c); } } } // new composed text insertion if (!isViewer() && doc.isWritable()) { int composedTextIndex = text.getIndex(); if (composedTextIndex < text.getEndIndex()) { createComposedString(composedTextIndex, text); runUndoTransparent(new Runnable() { @Override public void run() { EditorModificationUtil.insertStringAtCaret(EditorImpl.this, composedText, false, false); } }); composedTextRange = ProperTextRange.from(getCaretModel().getOffset(), composedText.length()); } } } }