diff --git a/src/vs/workbench/api/node/extHostTypes.ts b/src/vs/workbench/api/node/extHostTypes.ts index 7edb9a9045c5f..21fb78b59f8e3 100644 --- a/src/vs/workbench/api/node/extHostTypes.ts +++ b/src/vs/workbench/api/node/extHostTypes.ts @@ -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'); + } } } diff --git a/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts b/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts index c25d55334b8b7..50722a509fc41 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts @@ -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); - }); }); });