mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
ensure a range contains its previous range, #63935
This commit is contained in:
@@ -861,11 +861,19 @@ class SelectionRangeAdapter {
|
||||
const { document } = this._documents.getDocumentData(resource);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
return asThenable(() => this._provider.provideSelectionRanges(document, pos, token)).then(ranges => {
|
||||
if (isNonEmptyArray(ranges)) {
|
||||
return ranges.map(typeConvert.Range.from);
|
||||
} else {
|
||||
if (isFalsyOrEmpty(ranges)) {
|
||||
return undefined;
|
||||
}
|
||||
let result: IRange[] = [];
|
||||
let last: vscode.Position | vscode.Range = pos;
|
||||
for (const range of ranges) {
|
||||
if (!range.contains(last)) {
|
||||
throw new Error('INVALID selection range, must contain the previous range');
|
||||
}
|
||||
result.push(typeConvert.Range.from(range));
|
||||
last = range;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user