refactor: pass withChain boolean and remove console.logs
This commit is contained in:
parent
c9acabe58f
commit
a14c1bf397
3 changed files with 41 additions and 27 deletions
|
|
@ -593,6 +593,7 @@ export class Core {
|
|||
const outcome = await this.nextEditProvider.provideInlineCompletionItems(
|
||||
msg.data,
|
||||
undefined,
|
||||
false,
|
||||
);
|
||||
return outcome ? [outcome.completion, outcome.originalEditableRange] : [];
|
||||
});
|
||||
|
|
|
|||
|
|
@ -140,6 +140,14 @@ export class ContinueCompletionProvider
|
|||
token: vscode.CancellationToken,
|
||||
//@ts-ignore
|
||||
): ProviderResult<InlineCompletionItem[] | InlineCompletionList> {
|
||||
console.log("================================================");
|
||||
console.log(
|
||||
"editor.inlineSuggest.enabled:",
|
||||
vscode.workspace
|
||||
.getConfiguration()
|
||||
.get<boolean>("editor.inlineSuggest.enabled"),
|
||||
);
|
||||
// console.log("trigger!!", token.isCancellationRequested);
|
||||
const enableTabAutocomplete =
|
||||
getStatusBarStatus() === StatusBarStatus.Enabled;
|
||||
if (token.isCancellationRequested || !enableTabAutocomplete) {
|
||||
|
|
@ -239,7 +247,12 @@ export class ContinueCompletionProvider
|
|||
const recentlyVisitedRanges = this.recentlyVisitedRanges.getSnippets();
|
||||
let recentlyEditedRanges =
|
||||
await this.recentlyEditedTracker.getRecentlyEditedRanges();
|
||||
console.log("one:", JSON.stringify(recentlyEditedRanges, null, 2));
|
||||
// console.log("one:", JSON.stringify(recentlyEditedRanges, null, 2));
|
||||
console.log(
|
||||
this.nextEditProvider.chainExists()
|
||||
? "chain is alive"
|
||||
: "chain is not alive",
|
||||
);
|
||||
|
||||
if (this.nextEditProvider.chainExists()) {
|
||||
// If the user has accepted the previous completion, the chain of edits is alive.
|
||||
|
|
@ -280,9 +293,33 @@ export class ContinueCompletionProvider
|
|||
outcome = await this.nextEditProvider.provideInlineCompletionItems(
|
||||
input,
|
||||
signal,
|
||||
false,
|
||||
);
|
||||
console.log("outcome.completion:");
|
||||
console.log(outcome?.completion);
|
||||
if (!outcome || !outcome.completion) {
|
||||
// TODO: At this point we assume that the user typed something "whole".
|
||||
// AKA, the user's edit was good enough to start an edit chain.
|
||||
// We actually started the chain before getting the outcome. This makes logical sense.
|
||||
// Then all we need to do is to calculate next editable region.
|
||||
// We also need to use the user's edits to create a user edits section in renderPrompt.
|
||||
recentlyEditedRanges =
|
||||
await this.recentlyEditedTracker.getRecentlyEditedRanges();
|
||||
// console.log("two:", JSON.stringify(recentlyEditedRanges, null, 2));
|
||||
outcome =
|
||||
await this.nextEditProvider.provideInlineCompletionItemsWithChain(
|
||||
{
|
||||
completionId,
|
||||
manuallyPassFileContents,
|
||||
manuallyPassPrefix,
|
||||
selectedCompletionInfo,
|
||||
isUntitledFile: document.isUntitled,
|
||||
recentlyVisitedRanges,
|
||||
recentlyEditedRanges,
|
||||
},
|
||||
signal,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
outcome = await this.completionProvider.provideInlineCompletionItems(
|
||||
input,
|
||||
|
|
@ -308,30 +345,7 @@ export class ContinueCompletionProvider
|
|||
// );
|
||||
|
||||
if (!outcome || !outcome.completion) {
|
||||
// TODO: At this point we assume that the user typed something "whole".
|
||||
// AKA, the user's edit was good enough to start an edit chain.
|
||||
// We actually started the chain before getting the outcome. This makes logical sense.
|
||||
// Then all we need to do is to calculate next editable region.
|
||||
// We also need to use the user's edits to create a user edits section in renderPrompt.
|
||||
recentlyEditedRanges =
|
||||
await this.recentlyEditedTracker.getRecentlyEditedRanges();
|
||||
console.log("two:", JSON.stringify(recentlyEditedRanges, null, 2));
|
||||
outcome =
|
||||
await this.nextEditProvider.provideInlineCompletionItemsWithChain(
|
||||
{
|
||||
completionId,
|
||||
manuallyPassFileContents,
|
||||
manuallyPassPrefix,
|
||||
selectedCompletionInfo,
|
||||
isUntitledFile: document.isUntitled,
|
||||
recentlyVisitedRanges,
|
||||
recentlyEditedRanges,
|
||||
},
|
||||
signal,
|
||||
);
|
||||
if (!outcome || !outcome.completion) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// VS Code displays dependent on selectedCompletionInfo (their docstring below)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import { ConfigYamlDocumentLinkProvider } from "./ConfigYamlDocumentLinkProvider
|
|||
import { VsCodeMessenger } from "./VsCodeMessenger";
|
||||
|
||||
import { getAst } from "core/autocomplete/util/ast";
|
||||
import { DocumentAstTracker } from "core/nextEdit/DocumentAstTracker";
|
||||
import { DocumentAstTracker } from "core/nextEdit/DocumentHistoryTracker";
|
||||
import {
|
||||
EditableRegionStrategy,
|
||||
getNextEditableRegion,
|
||||
|
|
@ -383,7 +383,6 @@ export class VsCodeExtension {
|
|||
vscode.workspace.onDidOpenTextDocument(async (event) => {
|
||||
console.log("onDidOpenTextDocument");
|
||||
const ast = await getAst(event.fileName, event.getText());
|
||||
console.log(ast === undefined);
|
||||
if (ast) {
|
||||
DocumentAstTracker.getInstance().addDocument(
|
||||
localPathOrUriToPath(event.fileName),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue