Fix/autocomplete errors (#1007)
* fix: tab autocomplete URL and remove unnecessary code * fix: formatting issues in completionProvider.ts * remove: error handling in ContinueCompletionProvider
This commit is contained in:
parent
740d03467c
commit
ef282d194b
2 changed files with 26 additions and 26 deletions
|
|
@ -53,7 +53,7 @@ const autocompleteCache = AutocompleteLruCache.get();
|
|||
function formatExternalSnippet(
|
||||
filepath: string,
|
||||
snippet: string,
|
||||
language: AutocompleteLanguageInfo,
|
||||
language: AutocompleteLanguageInfo
|
||||
) {
|
||||
const comment = language.comment;
|
||||
const lines = [
|
||||
|
|
@ -78,8 +78,8 @@ export async function getTabCompletion(
|
|||
filepath: string,
|
||||
contents: string,
|
||||
cursorIndex: number,
|
||||
ide: IDE,
|
||||
) => Promise<AutocompleteSnippet[]>,
|
||||
ide: IDE
|
||||
) => Promise<AutocompleteSnippet[]>
|
||||
): Promise<AutocompleteOutcome | undefined> {
|
||||
const startTime = Date.now();
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ export async function getTabCompletion(
|
|||
filepath,
|
||||
fullPrefix + fullSuffix,
|
||||
fullPrefix.length,
|
||||
ide,
|
||||
ide
|
||||
),
|
||||
new Promise((resolve) => {
|
||||
setTimeout(() => resolve([]), 100);
|
||||
|
|
@ -155,7 +155,7 @@ export async function getTabCompletion(
|
|||
recentlyEditedRanges,
|
||||
recentlyEditedFiles,
|
||||
llm.model,
|
||||
extrasSnippets,
|
||||
extrasSnippets
|
||||
);
|
||||
|
||||
// Template prompt
|
||||
|
|
@ -172,7 +172,7 @@ export async function getTabCompletion(
|
|||
// Format snippets as comments and prepend to prefix
|
||||
const formattedSnippets = snippets
|
||||
.map((snippet) =>
|
||||
formatExternalSnippet(snippet.filepath, snippet.contents, lang),
|
||||
formatExternalSnippet(snippet.filepath, snippet.contents, lang)
|
||||
)
|
||||
.join("\n");
|
||||
if (formattedSnippets.length > 0) {
|
||||
|
|
@ -224,7 +224,7 @@ export async function getTabCompletion(
|
|||
raw: true,
|
||||
stop,
|
||||
}),
|
||||
multiline,
|
||||
multiline
|
||||
);
|
||||
|
||||
// LLM
|
||||
|
|
@ -241,13 +241,13 @@ export async function getTabCompletion(
|
|||
let chars = generatorWithCancellation();
|
||||
const gen2 = onlyWhitespaceAfterEndOfLine(
|
||||
noFirstCharNewline(chars),
|
||||
lang.endOfLine,
|
||||
lang.endOfLine
|
||||
);
|
||||
const lineGenerator = streamWithNewLines(
|
||||
avoidPathLine(
|
||||
stopAtRepeatingLines(stopAtLines(streamLines(gen2))),
|
||||
lang.comment,
|
||||
),
|
||||
lang.comment
|
||||
)
|
||||
);
|
||||
const finalGenerator = stopAtSimilarLine(lineGenerator, lineBelowCursor);
|
||||
for await (const update of finalGenerator) {
|
||||
|
|
@ -293,11 +293,11 @@ export class CompletionProvider {
|
|||
filepath: string,
|
||||
contents: string,
|
||||
cursorIndex: number,
|
||||
ide: IDE,
|
||||
) => Promise<AutocompleteSnippet[]>,
|
||||
ide: IDE
|
||||
) => Promise<AutocompleteSnippet[]>
|
||||
) {
|
||||
this.generatorReuseManager = new GeneratorReuseManager(
|
||||
this.onError.bind(this),
|
||||
this.onError.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -347,7 +347,7 @@ export class CompletionProvider {
|
|||
|
||||
public async provideInlineCompletionItems(
|
||||
input: AutocompleteInput,
|
||||
token: AbortSignal | undefined,
|
||||
token: AbortSignal | undefined
|
||||
): Promise<AutocompleteOutcome | undefined> {
|
||||
// Create abort signal if not given
|
||||
if (!token) {
|
||||
|
|
@ -372,7 +372,7 @@ export class CompletionProvider {
|
|||
const lastUUID = await new Promise((resolve) =>
|
||||
setTimeout(() => {
|
||||
resolve(CompletionProvider.lastUUID);
|
||||
}, options.debounceDelay),
|
||||
}, options.debounceDelay)
|
||||
);
|
||||
if (uuid !== lastUUID) {
|
||||
return undefined;
|
||||
|
|
@ -402,7 +402,7 @@ export class CompletionProvider {
|
|||
this.ide,
|
||||
this.generatorReuseManager,
|
||||
input,
|
||||
this.getDefinitionsFromLsp,
|
||||
this.getDefinitionsFromLsp
|
||||
);
|
||||
const completion = outcome?.completion;
|
||||
|
||||
|
|
@ -434,6 +434,8 @@ export class CompletionProvider {
|
|||
this._logRejectionTimeouts.set(input.completionId, logRejectionTimeout);
|
||||
|
||||
return outcome;
|
||||
} catch (e: any) {
|
||||
this.onError(e);
|
||||
} finally {
|
||||
this._abortControllers.delete(input.completionId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ export class ContinueCompletionProvider
|
|||
if (val === "Documentation") {
|
||||
vscode.env.openExternal(
|
||||
vscode.Uri.parse(
|
||||
"https://continue.dev/docs/walkthroughs/tab-autocomplete",
|
||||
),
|
||||
"https://continue.dev/docs/walkthroughs/tab-autocomplete"
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
@ -32,14 +32,14 @@ export class ContinueCompletionProvider
|
|||
constructor(
|
||||
private readonly configHandler: ConfigHandler,
|
||||
private readonly ide: IDE,
|
||||
private readonly tabAutocompleteModel: TabAutocompleteModel,
|
||||
private readonly tabAutocompleteModel: TabAutocompleteModel
|
||||
) {
|
||||
this.completionProvider = new CompletionProvider(
|
||||
this.configHandler,
|
||||
this.ide,
|
||||
this.tabAutocompleteModel.get.bind(this.tabAutocompleteModel),
|
||||
this.onError.bind(this),
|
||||
getDefinitionsFromLsp,
|
||||
getDefinitionsFromLsp
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ export class ContinueCompletionProvider
|
|||
document: vscode.TextDocument,
|
||||
position: vscode.Position,
|
||||
context: vscode.InlineCompletionContext,
|
||||
token: vscode.CancellationToken,
|
||||
token: vscode.CancellationToken
|
||||
//@ts-ignore
|
||||
): ProviderResult<InlineCompletionItem[] | InlineCompletionList> {
|
||||
const enableTabAutocomplete =
|
||||
|
|
@ -75,7 +75,7 @@ export class ContinueCompletionProvider
|
|||
const outcome =
|
||||
await this.completionProvider.provideInlineCompletionItems(
|
||||
input,
|
||||
signal,
|
||||
signal
|
||||
);
|
||||
|
||||
if (!outcome || !outcome.completion) {
|
||||
|
|
@ -100,17 +100,15 @@ export class ContinueCompletionProvider
|
|||
outcome.completion,
|
||||
new vscode.Range(
|
||||
position,
|
||||
position.translate(0, outcome.completion.length),
|
||||
position.translate(0, outcome.completion.length)
|
||||
),
|
||||
{
|
||||
title: "Log Autocomplete Outcome",
|
||||
command: "continue.logAutocompleteOutcome",
|
||||
arguments: [outcome, logRejectionTimeout],
|
||||
},
|
||||
}
|
||||
),
|
||||
];
|
||||
} catch (e: any) {
|
||||
this.onError(e);
|
||||
} finally {
|
||||
stopStatusBarLoading();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue