From 981863f8bc1c6ea87d8e6357e7f920e2d0f4b8ae Mon Sep 17 00:00:00 2001 From: Alex Plate Date: Thu, 29 Nov 2018 17:37:46 +0300 Subject: [PATCH] Disable retyper on focus lost --- .../src/com/intellij/internal/retype/RetypeSession.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/internal/retype/RetypeSession.kt b/platform/lang-impl/src/com/intellij/internal/retype/RetypeSession.kt index 8da42a9e61e4..da52d10d5b51 100644 --- a/platform/lang-impl/src/com/intellij/internal/retype/RetypeSession.kt +++ b/platform/lang-impl/src/com/intellij/internal/retype/RetypeSession.kt @@ -241,6 +241,9 @@ class RetypeSession( override fun dispose() { } + private fun inFocus(): Boolean = + editor.contentComponent == IdeFocusManager.findInstance().focusOwner && ApplicationManager.getApplication().isActive + private fun runLoop() { while (true) { if (pos == endPos || stopTimer) break @@ -267,7 +270,7 @@ class RetypeSession( private fun typeNextInEDT(timerTick: Long, expectedTimerTick: Long) { if (retypePaused) { - if (editor.contentComponent == IdeFocusManager.findInstance().focusOwner) { + if (inFocus()) { // Resume retyping on editor focus retypePaused = false } @@ -307,7 +310,7 @@ class RetypeSession( } // Do not perform typing if editor is not in focus - if (editor.contentComponent != IdeFocusManager.findInstance().focusOwner) retypePaused = true + if (!inFocus()) retypePaused = true if (retypePaused) { checkStop()