From 1d5136fbcb1a2e00dfc3eaf3b234e42025cf7e35 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Fri, 23 Nov 2018 14:38:10 +0300 Subject: [PATCH] =?UTF-8?q?IDEA-202801=20Input=20of=20Yen=20character=20(?= =?UTF-8?q?=C2=A5)=20deletes=20previously=20typed=20character=20in=20edito?= =?UTF-8?q?r=20(on=20macOS)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/intellij/openapi/editor/impl/EditorImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 4a1ee07bcb8f..42cbcd0ecc8a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -3720,10 +3720,16 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi () -> CommandProcessor.getInstance().executeCommand(myProject, () -> ApplicationManager.getApplication().runWriteAction(runnable), "", getDocument(), UndoConfirmationPolicy.DEFAULT, getDocument())); } + private boolean hasRelevantCommittedText(@NotNull InputMethodEvent e) { + if (e.getCommittedCharacterCount() <= 0) return false; + AttributedCharacterIterator text = e.getText(); + return text == null || text.first() != 0xA5 /* Yen character */; + } + private void replaceInputMethodText(@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))) { + (hasRelevantCommittedText(e) || 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.