Skip to content

Commit

Permalink
Adopt pylance new api from prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Mar 17, 2024
1 parent 7e44bfd commit 54007ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/standalone/executionAnalysis/pylance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface INotebookLanguageClient {
},
token: vscode.CancellationToken
): Promise<LocationWithReferenceKind[] | null | undefined>;
getDocumentSymbols(
getDocumentSymbols?(
document: vscode.TextDocument,
token: vscode.CancellationToken
): Promise<vscode.DocumentSymbol[] | undefined>;
Expand Down
11 changes: 9 additions & 2 deletions src/standalone/executionAnalysis/symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,15 @@ export class NotebookDocumentSymbolTracker {
}

private async _getDocumentSymbols(cell: vscode.NotebookCell) {
const tokenSource = new vscode.CancellationTokenSource();
return this._client.getDocumentSymbols(cell.document, tokenSource.token);
if (this._client.getDocumentSymbols) {
const tokenSource = new vscode.CancellationTokenSource();
return this._client.getDocumentSymbols(cell.document, tokenSource.token);
} else {
return vscode.commands.executeCommand<(vscode.SymbolInformation & vscode.DocumentSymbol)[] | undefined>(
'vscode.executeDocumentSymbolProvider',
cell.document.uri
);
}
}

private async _doRequestCellSymbols(cell: vscode.NotebookCell, token: vscode.CancellationToken) {
Expand Down

0 comments on commit 54007ac

Please sign in to comment.