Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for notebook types in DocumentSelector #141143

Closed
jrieken opened this issue Jan 21, 2022 · 3 comments
Closed

Add support for notebook types in DocumentSelector #141143

jrieken opened this issue Jan 21, 2022 · 3 comments
Assignees
Labels
api api-finalization editor-symbols definitions, declarations, references feature-request Request for new features or functionality on-release-notes Issue/pull request mentioned in release notes verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@jrieken
Copy link
Member

jrieken commented Jan 21, 2022

Throughout the API the DocumentSelector is used to "bind" features like completions or code navigations against certain documents. However, it doesn't allows to narrow down on documents that are part of a notebook, extensions want to say python-language but only in jupyter-notebooks.

/cc @dbaeumer who brought this up for the notebook related LSP work

@jrieken
Copy link
Member Author

jrieken commented Feb 11, 2022

This is API delta/addition which complements the existing DocumentFilter:

export interface DocumentFilter {
/**
* The {@link NotebookDocument.notebookType type} of a notebook, like `jupyter`
*/
readonly notebookType?: string;
}

The presence of notebookType implicitly means that the scheme is vscode-notebook-cell (meaning it must be that value or undefined).


Also, the idea of also allowing to filter on notebook kernels/controllers didn't stick. A controller is a private object, meaning a controller that adds language features knows the current notebook and can filter on that, e.g in its onDidChangeSelectedNotebooks-handler it can create a filter targeting the notebook type and its path, like so

// controller-specific language feature
 myKernel.onDidChangeSelectedNotebooks(e => {

    vscode.languages.registerTypeDefinitionProvider({
        language: 'plaintext',
        pattern: e.notebook.uri.path,
        notebookType: e.notebook.notebookType
    }, new class implements vscode.TypeDefinitionProvider {
        provideTypeDefinition(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken) {

            return new vscode.Location(document.uri, new vscode.Position(0, 0));
        }
    })
 })

jrieken added a commit that referenced this issue Feb 11, 2022
mustard-mh pushed a commit to gitpod-io/openvscode-server that referenced this issue Feb 13, 2022
mustard-mh pushed a commit to gitpod-io/openvscode-server that referenced this issue Feb 13, 2022
mustard-mh pushed a commit to gitpod-io/openvscode-server that referenced this issue Feb 13, 2022
mustard-mh pushed a commit to gitpod-io/openvscode-server that referenced this issue Feb 13, 2022
mustard-mh pushed a commit to gitpod-io/openvscode-server that referenced this issue Feb 13, 2022
mustard-mh pushed a commit to gitpod-io/openvscode-server that referenced this issue Feb 13, 2022
@jrieken
Copy link
Member Author

jrieken commented Mar 14, 2022

When notebookType is set, change the meaning of scheme and pattern to be checked against the notebook values, not the cell document

@jrieken
Copy link
Member Author

jrieken commented Mar 21, 2022

@dbaeumer please verify that this is stable API now

@dbaeumer dbaeumer added the verified Verification succeeded label Mar 22, 2022
@jrieken jrieken added the on-release-notes Issue/pull request mentioned in release notes label Mar 23, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api api-finalization editor-symbols definitions, declarations, references feature-request Request for new features or functionality on-release-notes Issue/pull request mentioned in release notes verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

2 participants