allow to send onDidChangeInlayHints-event for specific uris,...

allow to send onDidChangeInlayHints-event for specific uris, https://github.com/microsoft/vscode/issues/130430
上级 9c6de0fb
......@@ -1755,7 +1755,7 @@ export interface InlayHint {
}
export interface InlayHintsProvider {
onDidChangeInlayHints?: Event<void> | undefined;
onDidChangeInlayHints?: Event<void | URI>;
provideInlayHints(model: model.ITextModel, range: Range, token: CancellationToken): ProviderResult<InlayHint[]>;
}
......
......@@ -151,7 +151,11 @@ export class InlayHintsController implements IEditorContribution {
this._sessionDisposables.add(providerListener);
for (const provider of InlayHintsProviderRegistry.all(model)) {
if (typeof provider.onDidChangeInlayHints === 'function') {
providerListener.add(provider.onDidChangeInlayHints(() => scheduler.schedule()));
providerListener.add(provider.onDidChangeInlayHints(uri => {
if (!uri || uri.toString() === model.uri.toString()) {
scheduler.schedule();
}
}));
}
}
}
......
......@@ -6685,7 +6685,7 @@ declare namespace monaco.languages {
}
export interface InlayHintsProvider {
onDidChangeInlayHints?: IEvent<void> | undefined;
onDidChangeInlayHints?: IEvent<void | Uri>;
provideInlayHints(model: editor.ITextModel, range: Range, token: CancellationToken): ProviderResult<InlayHint[]>;
}
......
......@@ -1844,7 +1844,7 @@ declare module 'vscode' {
* An optional event to signal that inlay hints have changed.
* @see {@link EventEmitter}
*/
onDidChangeInlayHints?: Event<void>;
onDidChangeInlayHints?: Event<undefined | Uri>;
/**
*
......
......@@ -16,13 +16,14 @@ import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageCo
import { LanguageConfiguration, IndentationRule, OnEnterRule } from 'vs/editor/common/modes/languageConfiguration';
import { IModeService } from 'vs/editor/common/services/modeService';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { URI } from 'vs/base/common/uri';
import { URI, UriComponents } from 'vs/base/common/uri';
import { Selection } from 'vs/editor/common/core/selection';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import * as callh from 'vs/workbench/contrib/callHierarchy/common/callHierarchy';
import * as typeh from 'vs/workbench/contrib/typeHierarchy/common/typeHierarchy';
import { mixin } from 'vs/base/common/objects';
import { decodeSemanticTokensDto } from 'vs/editor/common/services/semanticTokensDto';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
@extHostNamedCustomer(MainContext.MainThreadLanguageFeatures)
export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesShape {
......@@ -34,6 +35,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
constructor(
extHostContext: IExtHostContext,
@IModeService modeService: IModeService,
@IUriIdentityService private readonly _uriIdentService: IUriIdentityService,
) {
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostLanguageFeatures);
this._modeService = modeService;
......@@ -566,10 +568,10 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
this._registrations.set(handle, modes.InlayHintsProviderRegistry.register(selector, provider));
}
$emitInlayHintsEvent(eventHandle: number, event?: any): void {
$emitInlayHintsEvent(eventHandle: number, event?: UriComponents): void {
const obj = this._registrations.get(eventHandle);
if (obj instanceof Emitter) {
obj.fire(event);
obj.fire(event && this._uriIdentService.asCanonicalUri(URI.revive(event)));
}
}
......
......@@ -412,7 +412,7 @@ export interface MainThreadLanguageFeaturesShape extends IDisposable {
$registerInlineCompletionsSupport(handle: number, selector: IDocumentFilterDto[]): void;
$registerSignatureHelpProvider(handle: number, selector: IDocumentFilterDto[], metadata: ISignatureHelpProviderMetadataDto): void;
$registerInlayHintsProvider(handle: number, selector: IDocumentFilterDto[], eventHandle: number | undefined): void;
$emitInlayHintsEvent(eventHandle: number, event?: any): void;
$emitInlayHintsEvent(eventHandle: number, event?: UriComponents): void;
$registerDocumentLinkProvider(handle: number, selector: IDocumentFilterDto[], supportsResolve: boolean): void;
$registerDocumentColorProvider(handle: number, selector: IDocumentFilterDto[]): void;
$registerFoldingRangeProvider(handle: number, selector: IDocumentFilterDto[], eventHandle: number | undefined): void;
......
......@@ -1988,7 +1988,7 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
let result = this._createDisposable(handle);
if (eventHandle !== undefined) {
const subscription = provider.onDidChangeInlayHints!(_ => this._proxy.$emitInlayHintsEvent(eventHandle));
const subscription = provider.onDidChangeInlayHints!(uri => this._proxy.$emitInlayHintsEvent(eventHandle, uri));
result = Disposable.from(result, subscription);
}
return result;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册