mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-25 04:36:23 +00:00
use a parent pointer instead of 2d array, #67872
This commit is contained in:
@@ -90,16 +90,17 @@ export function activate(context: ExtensionContext) {
|
||||
|
||||
documentSelector.forEach(selector => {
|
||||
context.subscriptions.push(languages.registerSelectionRangeProvider(selector, {
|
||||
async provideSelectionRanges(document: TextDocument, positions: Position[]): Promise<SelectionRange[][]> {
|
||||
async provideSelectionRanges(document: TextDocument, positions: Position[]): Promise<SelectionRange[]> {
|
||||
const textDocument = client.code2ProtocolConverter.asTextDocumentIdentifier(document);
|
||||
const rawResult = await client.sendRequest<SelectionRange[][]>('$/textDocument/selectionRanges', { textDocument, positions: positions.map(client.code2ProtocolConverter.asPosition) });
|
||||
if (Array.isArray(rawResult)) {
|
||||
return rawResult.map(rawSelectionRanges => {
|
||||
return rawSelectionRanges.map(selectionRange => {
|
||||
return rawSelectionRanges.reduceRight((parent: SelectionRange | undefined, selectionRange: SelectionRange) => {
|
||||
return {
|
||||
range: client.protocol2CodeConverter.asRange(selectionRange.range),
|
||||
parent
|
||||
};
|
||||
});
|
||||
}, undefined)!;
|
||||
});
|
||||
}
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user