Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

# Provides handleRejection to the inline suggest providers in extensions #241328

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,11 @@ export class MainThreadLanguageFeatures extends Disposable implements MainThread
await this._proxy.$handleInlineCompletionPartialAccept(handle, completions.pid, item.idx, acceptedCharacters, info);
}
},
handleRejection: async (completions, item): Promise<void> => {
if (supportsHandleEvents) {
await this._proxy.$handleInlineCompletionRejection(handle, completions.pid, item.idx);
}
},
freeInlineCompletions: (completions: IdentifiableInlineCompletions): void => {
this._proxy.$freeInlineCompletionsList(handle, completions.pid);
},
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2333,6 +2333,7 @@ export interface ExtHostLanguageFeaturesShape {
$provideInlineEditsForRange(handle: number, resource: UriComponents, range: IRange, context: languages.InlineCompletionContext, token: CancellationToken): Promise<IdentifiableInlineCompletions | undefined>;
$handleInlineCompletionDidShow(handle: number, pid: number, idx: number, updatedInsertText: string): void;
$handleInlineCompletionPartialAccept(handle: number, pid: number, idx: number, acceptedCharacters: number, info: languages.PartialAcceptInfo): void;
$handleInlineCompletionRejection(handle: number, pid: number, idx: number): void;
$freeInlineCompletionsList(handle: number, pid: number): void;
$provideSignatureHelp(handle: number, resource: UriComponents, position: IPosition, context: languages.SignatureHelpContext, token: CancellationToken): Promise<ISignatureHelpDto | undefined>;
$releaseSignatureHelp(handle: number, id: number): void;
Expand Down
17 changes: 17 additions & 0 deletions src/vs/workbench/api/common/extHostLanguageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,8 @@ class InlineCompletionAdapterBase {
handleDidShowCompletionItem(pid: number, idx: number, updatedInsertText: string): void { }

handlePartialAccept(pid: number, idx: number, acceptedCharacters: number, info: languages.PartialAcceptInfo): void { }

handleRejection(pid: number, idx: number): void { }
}

class InlineCompletionAdapter extends InlineCompletionAdapterBase {
Expand Down Expand Up @@ -1538,6 +1540,15 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase {
}
}
}

override handleRejection(pid: number, idx: number): void {
const completionItem = this._references.get(pid)?.items[idx];
if (completionItem) {
if (this._provider.handleDidRejectCompletionItem && this._isAdditionsProposedApiEnabled) {
this._provider.handleDidRejectCompletionItem(completionItem);
}
}
}
}

class InlineEditAdapter {
Expand Down Expand Up @@ -2706,6 +2717,12 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
}, undefined, undefined);
}

$handleInlineCompletionRejection(handle: number, pid: number, idx: number): void {
this._withAdapter(handle, InlineCompletionAdapterBase, async adapter => {
adapter.handleRejection(pid, idx);
}, undefined, undefined);
}

$freeInlineCompletionsList(handle: number, pid: number): void {
this._withAdapter(handle, InlineCompletionAdapterBase, async adapter => { adapter.disposeCompletions(pid); }, undefined, undefined);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ declare module 'vscode' {
// eslint-disable-next-line local/vscode-dts-provider-naming
handleDidPartiallyAcceptCompletionItem?(completionItem: InlineCompletionItem, info: PartialAcceptInfo): void;

/**
* Is called when an inline completion item was rejected.
* @param completionItem The completion item that was rejected.
*/
// eslint-disable-next-line local/vscode-dts-provider-naming
handleDidRejectCompletionItem?(completionItem: InlineCompletionItem): void;

provideInlineEditsForRange?(document: TextDocument, range: Range, context: InlineCompletionContext, token: CancellationToken): ProviderResult<InlineCompletionItem[] | InlineCompletionList>;

readonly debounceDelayMs?: number;
Expand Down