@Override
  protected @NotNull DocumentEx createDocument(@NotNull CharSequence text, @NotNull VirtualFile file) {
    boolean acceptSlashR = file instanceof LightVirtualFile && StringUtil.indexOf(text, '\r') >= 0;
    boolean freeThreaded = Boolean.TRUE.equals(file.getUserData(AbstractFileViewProvider.FREE_THREADED));
    DocumentImpl document = (DocumentImpl)((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(text, acceptSlashR, freeThreaded);
    Project project = ProjectUtil.guessProjectForFile(file);
    int tabSize = project == null ? CodeStyle.getDefaultSettings().getTabSize(file.getFileType())  : CodeStyle.getFacade(project, document, file.getFileType()).getTabSize();
    // calculate and pass tab size here since it's the ony place we have access to CodeStyle.
    // tabSize might be needed by PersistentRangeMarkers to be able to restore from (line;col) info to offset
    document.documentCreatedFrom(file, tabSize);
    return document;
  }
@Override
  protected @NotNull DocumentEx createDocument(@NotNull CharSequence text, @NotNull VirtualFile file)