int (@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final String key) { ThreadingAssertions.assertEventDispatchThread(); final int currentOffset = editor.getCaretModel().getOffset(); final int newOffset = currentOffset - key.length(); ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().runUndoTransparentAction(() -> { Document document = editor.getDocument(); document.deleteString(newOffset, currentOffset); editor.getCaretModel().moveToOffset(newOffset); PsiDocumentManager.getInstance(file.getProject()).commitDocument(document); })); return newOffset; }