mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-26 05:07:35 +00:00
update proposed api to have multiple positions, #41838
This commit is contained in:
@@ -90,18 +90,20 @@ export function activate(context: ExtensionContext) {
|
||||
|
||||
documentSelector.forEach(selector => {
|
||||
context.subscriptions.push(languages.registerSelectionRangeProvider(selector, {
|
||||
async provideSelectionRanges(document: TextDocument, position: Position): Promise<SelectionRange[]> {
|
||||
async provideSelectionRanges(document: TextDocument, positions: Position[]): Promise<SelectionRange[][]> {
|
||||
const textDocument = client.code2ProtocolConverter.asTextDocumentIdentifier(document);
|
||||
const rawRanges = await client.sendRequest<Range[]>('$/textDocument/selectionRange', { textDocument, position });
|
||||
if (Array.isArray(rawRanges)) {
|
||||
return rawRanges.map(r => {
|
||||
return {
|
||||
range: client.protocol2CodeConverter.asRange(r),
|
||||
kind: SelectionRangeKind.Declaration
|
||||
};
|
||||
});
|
||||
}
|
||||
return [];
|
||||
return Promise.all(positions.map(async position => {
|
||||
const rawRanges = await client.sendRequest<Range[]>('$/textDocument/selectionRange', { textDocument, position });
|
||||
if (Array.isArray(rawRanges)) {
|
||||
return rawRanges.map(r => {
|
||||
return {
|
||||
range: client.protocol2CodeConverter.asRange(r),
|
||||
kind: SelectionRangeKind.Declaration
|
||||
};
|
||||
});
|
||||
}
|
||||
return [];
|
||||
}));
|
||||
}
|
||||
}));
|
||||
});
|
||||
@@ -206,4 +208,4 @@ function readJSONFile(location: string) {
|
||||
|
||||
export function deactivate(): Promise<any> {
|
||||
return telemetryReporter ? telemetryReporter.dispose() : Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user