提交 8579e43d 编写于 作者: J Johannes Rieken

check parent range when creating selection range, #67872

上级 a2f6ec67
......@@ -1103,6 +1103,10 @@ export class SelectionRange {
constructor(range: Range, parent?: SelectionRange) {
this.range = range;
this.parent = parent;
if (parent && !parent.range.contains(this.range)) {
throw new Error('Invalid argument: parent must contain this range');
}
}
}
......
......@@ -1119,19 +1119,15 @@ suite('ExtHostLanguageFeatures', function () {
});
test('Selection Ranges, bad data', async () => {
disposables.push(extHost.registerSelectionRangeProvider(defaultExtension, defaultSelector, new class implements vscode.SelectionRangeProvider {
provideSelectionRanges() {
return [
new types.SelectionRange(new types.Range(0, 10, 0, 18),
new types.SelectionRange(new types.Range(0, 11, 0, 18))),
];
}
}));
await rpcProtocol.sync();
try {
let _a = new types.SelectionRange(new types.Range(0, 10, 0, 18),
new types.SelectionRange(new types.Range(0, 11, 0, 18))
);
assert.ok(false, String(_a));
} catch (err) {
assert.ok(true);
}
provideSelectionRanges(model, [new Position(1, 17)], CancellationToken.None).then(ranges => {
assert.equal(ranges.length, 0);
});
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册