@Nullable
  private static Editor getEditor(@NotNull Project project, @Nullable Editor editor, @NotNull VirtualFile file) {
    if (editor == null) return getEditor(project, file);
    VirtualFile editorVirtualFile = editor.getVirtualFile(); // EditorComboBox and similar components might provide no virtual file
    if (editorVirtualFile != null &&
        !file.equals(editorVirtualFile) && !editor.getDocument().equals(FileDocumentManager.getInstance().getDocument(file))) {
      return getEditor(project, file);
    }
    else {
      return editor;
    }
  }
@Nullable
  private static Editor getEditor(@NotNull Project project, @Nullable Editor editor, @NotNull VirtualFile file)