From b7ca72a251a41f25c79f40f707dae79818445d62 Mon Sep 17 00:00:00 2001 From: Alexandr Suhinin Date: Thu, 1 Feb 2024 10:12:04 +0200 Subject: [PATCH] EA-1047558 [extract method]: revert editor state inside write action always GitOrigin-RevId: f6ca59b7c1ee5a60fe42a2b14925e37d730d601c --- .../newImpl/inplace/EditorState.kt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/java/java-impl-refactorings/src/com/intellij/refactoring/extractMethod/newImpl/inplace/EditorState.kt b/java/java-impl-refactorings/src/com/intellij/refactoring/extractMethod/newImpl/inplace/EditorState.kt index b3fd22747578..ca588b4fbd6d 100644 --- a/java/java-impl-refactorings/src/com/intellij/refactoring/extractMethod/newImpl/inplace/EditorState.kt +++ b/java/java-impl-refactorings/src/com/intellij/refactoring/extractMethod/newImpl/inplace/EditorState.kt @@ -17,19 +17,18 @@ class EditorState(val project: Project, val editor: Editor){ private val textToRevert: String = editor.document.text fun revert() { - val undoManager = UndoManager.getInstance(project) - WriteAction.run { - if (undoManager.isUndoOrRedoInProgress) { - ApplicationManager.getApplication().invokeLater { revertWithoutPostprocessing(project) } - } - else { - revertWithoutPostprocessing(project) - } + if (UndoManager.getInstance(project).isUndoOrRedoInProgress) { + ApplicationManager.getApplication().invokeLater { revertWithoutPostprocessing() } + } + else { + revertWithoutPostprocessing() } } - private fun revertWithoutPostprocessing(project: Project) { + private fun revertWithoutPostprocessing() { + WriteAction.run { PostprocessReformattingAspect.getInstance(project).disablePostprocessFormattingInside(::revertState) + } } private fun revertState() {