mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:28:52 +01:00
Fixes issues from code review
This commit is contained in:
@@ -1037,10 +1037,10 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase {
|
||||
items: readonly vscode.InlineCompletionItem[];
|
||||
}>();
|
||||
|
||||
private readonly isAdditionProposedApiEnabled = isProposedApiEnabled(this.extension, 'inlineCompletionsAdditions');
|
||||
private readonly _isAdditionsProposedApiEnabled = isProposedApiEnabled(this._extension, 'inlineCompletionsAdditions');
|
||||
|
||||
constructor(
|
||||
private readonly extension: IExtensionDescription,
|
||||
private readonly _extension: IExtensionDescription,
|
||||
private readonly _documents: ExtHostDocuments,
|
||||
private readonly _provider: vscode.InlineCompletionItemProvider,
|
||||
private readonly _commands: CommandsConverter,
|
||||
@@ -1048,6 +1048,10 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase {
|
||||
super();
|
||||
}
|
||||
|
||||
public get supportsHandleDidShowCompletionItem(): boolean {
|
||||
return isProposedApiEnabled(this._extension, 'inlineCompletionsAdditions') && typeof this._provider.handleDidShowCompletionItem === 'function';
|
||||
}
|
||||
|
||||
private readonly languageTriggerKindToVSCodeTriggerKind: Record<languages.InlineCompletionTriggerKind, InlineCompletionTriggerKind> = {
|
||||
[languages.InlineCompletionTriggerKind.Automatic]: InlineCompletionTriggerKind.Automatic,
|
||||
[languages.InlineCompletionTriggerKind.Explicit]: InlineCompletionTriggerKind.Invoke,
|
||||
@@ -1080,7 +1084,7 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase {
|
||||
}
|
||||
|
||||
const normalizedResult = isArray(result) ? result : result.items;
|
||||
const commands = isArray(result) ? [] : result.commands || [];
|
||||
const commands = this._isAdditionsProposedApiEnabled ? isArray(result) ? [] : result.commands || [] : [];
|
||||
|
||||
let disposableStore: DisposableStore | undefined = undefined;
|
||||
const pid = this._references.createReferenceId({
|
||||
@@ -1110,7 +1114,7 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase {
|
||||
range: item.range ? typeConvert.Range.from(item.range) : undefined,
|
||||
command,
|
||||
idx: idx,
|
||||
completeBracketPairs: this.isAdditionProposedApiEnabled ? item.completeBracketPairs : false
|
||||
completeBracketPairs: this._isAdditionsProposedApiEnabled ? item.completeBracketPairs : false
|
||||
});
|
||||
}),
|
||||
commands: commands.map(c => {
|
||||
@@ -1130,7 +1134,7 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase {
|
||||
override handleDidShowCompletionItem(pid: number, idx: number): void {
|
||||
const completionItem = this._references.get(pid)?.items[idx];
|
||||
if (completionItem) {
|
||||
if (this._provider.handleDidShowCompletionItem && this.isAdditionProposedApiEnabled) {
|
||||
if (this._provider.handleDidShowCompletionItem && this._isAdditionsProposedApiEnabled) {
|
||||
this._provider.handleDidShowCompletionItem(completionItem);
|
||||
}
|
||||
}
|
||||
@@ -2204,14 +2208,15 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
|
||||
// --- ghost test
|
||||
|
||||
registerInlineCompletionsProvider(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.InlineCompletionItemProvider): vscode.Disposable {
|
||||
const handle = this._addNewAdapter(new InlineCompletionAdapter(extension, this._documents, provider, this._commands.converter), extension);
|
||||
this._proxy.$registerInlineCompletionsSupport(handle, this._transformDocumentSelector(selector));
|
||||
const adapter = new InlineCompletionAdapter(extension, this._documents, provider, this._commands.converter);
|
||||
const handle = this._addNewAdapter(adapter, extension);
|
||||
this._proxy.$registerInlineCompletionsSupport(handle, this._transformDocumentSelector(selector), adapter.supportsHandleDidShowCompletionItem);
|
||||
return this._createDisposable(handle);
|
||||
}
|
||||
|
||||
registerInlineCompletionsProviderNew(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.InlineCompletionItemProviderNew): vscode.Disposable {
|
||||
const handle = this._addNewAdapter(new InlineCompletionAdapterNew(extension, this._documents, provider, this._commands.converter), extension);
|
||||
this._proxy.$registerInlineCompletionsSupport(handle, this._transformDocumentSelector(selector));
|
||||
this._proxy.$registerInlineCompletionsSupport(handle, this._transformDocumentSelector(selector), true);
|
||||
return this._createDisposable(handle);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user