void (final Runnable runnable) { final Ref<Boolean> greedyToRight = new Ref<>(); runWriteCommandAction(myProject, getCommandName(), getCommandName(), () -> { PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument()); ASTNode identifier = myDeclaration.getNode().findChildByType(KtTokens.IDENTIFIER); if (identifier != null) { TextRange range = identifier.getTextRange(); RangeHighlighter[] highlighters = myEditor.getMarkupModel().getAllHighlighters(); for (RangeHighlighter highlighter : highlighters) { if (highlighter.getStartOffset() == range.getStartOffset()) { if (highlighter.getEndOffset() == range.getEndOffset()) { greedyToRight.set(highlighter.isGreedyToRight()); highlighter.setGreedyToRight(false); } } } } runnable.run(); TemplateState templateState = TemplateManagerImpl.getTemplateState(InjectedLanguageUtil.getTopLevelEditor(myEditor)); if (templateState != null) { myEditor.putUserData(INTRODUCE_RESTART, true); templateState.gotoEnd(true); } }); ApplicationManager.getApplication().runReadAction(() -> { ASTNode identifier = myDeclaration.getNode().findChildByType(KtTokens.IDENTIFIER); if (identifier != null) { TextRange range = identifier.getTextRange(); RangeHighlighter[] highlighters = myEditor.getMarkupModel().getAllHighlighters(); for (RangeHighlighter highlighter : highlighters) { if (highlighter.getStartOffset() == range.getStartOffset()) { if (highlighter.getEndOffset() == range.getEndOffset()) { highlighter.setGreedyToRight(greedyToRight.get()); } } } } }); if (myEditor.getUserData(INTRODUCE_RESTART) == Boolean.TRUE) { myInitialName = myDeclaration.getName(); performInplaceRefactoring(getSuggestionsForNextRun()); } }