diff --git a/src/vs/editor/contrib/wordHighlighter/browser/wordHighlighter.ts b/src/vs/editor/contrib/wordHighlighter/browser/wordHighlighter.ts index 525af0230a0da..f7bd8e2eededb 100644 --- a/src/vs/editor/contrib/wordHighlighter/browser/wordHighlighter.ts +++ b/src/vs/editor/contrib/wordHighlighter/browser/wordHighlighter.ts @@ -253,9 +253,10 @@ function computeOccurencesMultiModel(registry: LanguageFeatureRegistry { +registerModelAndPositionCommand('_executeDocumentHighlights', async (accessor, model, position) => { const languageFeaturesService = accessor.get(ILanguageFeaturesService); - return getOccurrencesAtPosition(languageFeaturesService.documentHighlightProvider, model, position, CancellationToken.None); + const map = await getOccurrencesAtPosition(languageFeaturesService.documentHighlightProvider, model, position, CancellationToken.None); + return map?.get(model.uri); }); class WordHighlighter { diff --git a/src/vs/workbench/api/test/browser/extHostApiCommands.test.ts b/src/vs/workbench/api/test/browser/extHostApiCommands.test.ts index 35e7543d86466..3a60e4c025ba3 100644 --- a/src/vs/workbench/api/test/browser/extHostApiCommands.test.ts +++ b/src/vs/workbench/api/test/browser/extHostApiCommands.test.ts @@ -681,6 +681,33 @@ suite('ExtHostLanguageFeatureCommands', function () { }); }); + // --- document highlights + + test('"vscode.executeDocumentHighlights" API has stopped returning DocumentHighlight[]#200056', async function () { + + + disposables.push(extHost.registerDocumentHighlightProvider(nullExtensionDescription, defaultSelector, { + provideDocumentHighlights() { + return [ + new types.DocumentHighlight(new types.Range(0, 17, 0, 25), types.DocumentHighlightKind.Read) + ]; + } + })); + + await rpcProtocol.sync(); + + return commands.executeCommand('vscode.executeDocumentHighlights', model.uri, new types.Position(0, 0)).then(values => { + assert.ok(Array.isArray(values)); + assert.strictEqual(values.length, 1); + const [first] = values; + assert.strictEqual(first.range.start.line, 0); + assert.strictEqual(first.range.start.character, 17); + assert.strictEqual(first.range.end.line, 0); + assert.strictEqual(first.range.end.character, 25); + }); + + }); + // --- outline test('Outline, back and forth', function () {