mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:28:52 +01:00
Fixes a bug that prevented new proposed inline completion API from working.
This commit is contained in:
@@ -1024,7 +1024,13 @@ class SuggestAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
class InlineCompletionAdapter {
|
||||
class InlineCompletionAdapterBase {
|
||||
public async provideInlineCompletions(resource: URI, position: IPosition, context: languages.InlineCompletionContext, token: CancellationToken): Promise<extHostProtocol.IdentifiableInlineCompletions | undefined> {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
class InlineCompletionAdapter extends InlineCompletionAdapterBase {
|
||||
private readonly _cache = new Cache<vscode.InlineCompletionItem>('InlineCompletionItem');
|
||||
private readonly _disposables = new Map<number, DisposableStore>();
|
||||
|
||||
@@ -1032,9 +1038,11 @@ class InlineCompletionAdapter {
|
||||
private readonly _documents: ExtHostDocuments,
|
||||
private readonly _provider: vscode.InlineCompletionItemProvider,
|
||||
private readonly _commands: CommandsConverter,
|
||||
) { }
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
public async provideInlineCompletions(resource: URI, position: IPosition, context: languages.InlineCompletionContext, token: CancellationToken): Promise<extHostProtocol.IdentifiableInlineCompletions | undefined> {
|
||||
public override async provideInlineCompletions(resource: URI, position: IPosition, context: languages.InlineCompletionContext, token: CancellationToken): Promise<extHostProtocol.IdentifiableInlineCompletions | undefined> {
|
||||
const doc = this._documents.getDocument(resource);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
@@ -1113,7 +1121,7 @@ class InlineCompletionAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
class InlineCompletionAdapterNew {
|
||||
class InlineCompletionAdapterNew extends InlineCompletionAdapterBase {
|
||||
private readonly _cache = new Cache<vscode.InlineCompletionItemNew>('InlineCompletionItemNew');
|
||||
private readonly _disposables = new Map<number, DisposableStore>();
|
||||
|
||||
@@ -1124,14 +1132,16 @@ class InlineCompletionAdapterNew {
|
||||
private readonly _documents: ExtHostDocuments,
|
||||
private readonly _provider: vscode.InlineCompletionItemProviderNew,
|
||||
private readonly _commands: CommandsConverter,
|
||||
) { }
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
private readonly languageTriggerKindToVSCodeTriggerKind: Record<languages.InlineCompletionTriggerKind, vscode.InlineCompletionTriggerKindNew> = {
|
||||
[languages.InlineCompletionTriggerKind.Automatic]: InlineCompletionTriggerKindNew.Automatic,
|
||||
[languages.InlineCompletionTriggerKind.Explicit]: InlineCompletionTriggerKindNew.Invoke,
|
||||
};
|
||||
|
||||
public async provideInlineCompletions(resource: URI, position: IPosition, context: languages.InlineCompletionContext, token: CancellationToken): Promise<extHostProtocol.IdentifiableInlineCompletions | undefined> {
|
||||
public override async provideInlineCompletions(resource: URI, position: IPosition, context: languages.InlineCompletionContext, token: CancellationToken): Promise<extHostProtocol.IdentifiableInlineCompletions | undefined> {
|
||||
const doc = this._documents.getDocument(resource);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
@@ -2156,7 +2166,7 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
|
||||
}
|
||||
|
||||
$provideInlineCompletions(handle: number, resource: UriComponents, position: IPosition, context: languages.InlineCompletionContext, token: CancellationToken): Promise<extHostProtocol.IdentifiableInlineCompletions | undefined> {
|
||||
return this._withAdapter(handle, InlineCompletionAdapter, adapter => adapter.provideInlineCompletions(URI.revive(resource), position, context, token), undefined, token);
|
||||
return this._withAdapter(handle, InlineCompletionAdapterBase, adapter => adapter.provideInlineCompletions(URI.revive(resource), position, context, token), undefined, token);
|
||||
}
|
||||
|
||||
$handleInlineCompletionDidShow(handle: number, pid: number, idx: number): void {
|
||||
|
||||
Reference in New Issue
Block a user