Editor (@NotNull String name, @NotNull String text) { VirtualFile myVFile = WriteAction.compute(() -> { try { VirtualFile file = getSourceRoot().createChildData(null, name); VfsUtil.saveText(file, text); return file; } catch (IOException e) { throw new RuntimeException(e); } }); final FileDocumentManager manager = FileDocumentManager.getInstance(); final Document document = manager.getDocument(myVFile); manager.reloadFromDisk(document); Editor editor = createEditor(myVFile); EditorTestUtil.CaretAndSelectionState caretsState = EditorTestUtil.extractCaretAndSelectionMarkers(document); EditorTestUtil.setCaretsAndSelection(editor, caretsState); return editor; }