void (@NotNull LogicalPosition position, @NotNull Editor editor, final @NotNull Project project) { final Document document = editor.getDocument(); final CaretModel caretModel = editor.getCaretModel(); final int endLineOffset = document.getLineEndOffset(position.line); final LogicalPosition endLinePosition = editor.offsetToLogicalPosition(endLineOffset); if (endLinePosition.column < position.column && !editor.getSettings().isVirtualSpace() && !editor.isViewer()) { final String toInsert = StringUtil.repeat(" ", position.column - endLinePosition.column); ApplicationManager.getApplication().runWriteAction(() -> { document.insertString(endLineOffset, toInsert); PsiDocumentManager.getInstance(project).commitDocument(document); }); } caretModel.moveToLogicalPosition(position); }