Skip to content

Notebook diff not compatible with readonly files from TextDocumentContentProvider - only checks IFileService for a IFileSystemProvider #209017

@rehmsen

Description

@rehmsen

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: vscode.dev
  • OS Version: macOS Sonoma 14.4.1 (23E224)

Steps to Reproduce:

  1. Have an extension that registers a TextDocumentContentProvider with a different "scheme", like "my-scheme://".
  2. Try to open a notebook diff where the left side is served via "my-scheme://".

Expected:

The notebook diff can be opened with a left hand side provided via a TextDocumentContentProvider.

Actual:

It fails in this line, because it requires the fileService to have aIFileSystemProvider for it:

canSupportResource: (resource: URI) => resource.scheme === Schemas.untitled || resource.scheme === Schemas.vscodeNotebookCell || this._fileService.hasProvider(resource)

Preliminary investigation and assumptions:

My (possibly incorrect) understanding of the provided abstractions and concepts is:

  • TextDocumentContentProvider is for readonly documents (such as some historic version in a VCS):
    * A text document content provider allows to add readonly documents
    * to the editor, such as source from a dll or generated html from md.
    *
    * Content providers are {@link workspace.registerTextDocumentContentProvider registered}
    * for a {@link Uri.scheme uri-scheme}. When a uri with that scheme is to
    * be {@link workspace.openTextDocument loaded} the content provider is
    * asked.
    */
    export interface TextDocumentContentProvider {
  • FileSystemProvider is for file systems that allow reading and writing:
    * The filesystem provider defines what the editor needs to read, write, discover,
    * and to manage files and folders. It allows extensions to serve files from remote places,
    * like ftp-servers, and to seamlessly integrate those into the editor.
    *
    * * *Note 1:* The filesystem provider API works with {@link Uri uris} and assumes hierarchical
    * paths, e.g. `foo:/my/path` is a child of `foo:/my/` and a parent of `foo:/my/path/deeper`.
    * * *Note 2:* There is an activation event `onFileSystem:<scheme>` that fires when a file
    * or folder is being accessed.
    * * *Note 3:* The word 'file' is often used to denote all {@link FileType kinds} of files, e.g.
    * folders, symbolic links, and regular files.
    */
    export interface FileSystemProvider {
  • The left hand side of a diff cannot be edited - this should be true both for regular and notebook diffs.

The TextDocumentContentProviders seem to be registered with the ITextModelService - I think Notebook diff should possibly check that instead of the FileService to see if the "my-scheme://" is supported? This check seems to have been added here: #122627 (comment)
#122658

Maybe @jrieken can advise on how to get the notebook diff viewer to work with readonly files from TextDocumentContentProvider schemes?

Metadata

Metadata

Assignees

Labels

apibugIssue identified by VS Code Team member as probable bugnotebook-diff

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions