Skip to content

Commit bf1b056

Browse files
committed
core : disable trimming of suggestions
1 parent c49ecfd commit bf1b056

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/architect.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ export class Architect {
4343
setStatusBar = (context: vscode.ExtensionContext) => {
4444
this.initializeStatusBar();
4545
this.registerEventListeners(context);
46-
46+
4747
context.subscriptions.push(
4848
vscode.commands.registerCommand('llama-vscode.showMenu', async () => {
4949
const currentLanguage = vscode.window.activeTextEditor?.document.languageId;
5050
const config = vscode.workspace.getConfiguration('llama-vscode');
5151
const languageSettings = config.get<Record<string, boolean>>('languageSettings') || {};
5252
const isLanguageEnabled = currentLanguage ? this.isCompletionEnabled(undefined, currentLanguage) : true;
53-
53+
5454
const items = this.createMenuItems(currentLanguage, isLanguageEnabled);
5555
const selected = await vscode.window.showQuickPick(items, { title: "Llama Menu" });
56-
56+
5757
if (selected) {
5858
await this.handleMenuSelection(selected, currentLanguage, languageSettings);
5959
}
@@ -320,7 +320,7 @@ export class Architect {
320320
delay = (ms: number) => {
321321
return new Promise<void>(resolve => setTimeout(resolve, ms));
322322
}
323-
323+
324324
addEventLog = (group: string, event: string, details: string) => {
325325
this.eventlogs.push(Date.now() + ", " + group + ", " + event + ", " + details.replace(",", " "));
326326
if (this.eventlogs.length > this.extConfig.MAX_EVENTS_IN_LOG) {
@@ -399,7 +399,10 @@ export class Architect {
399399
this.addEventLog(group, "DISCARD_SUGGESTION_RETURN", "")
400400
return [];
401401
}
402-
completion = this.updateSuggestion( suggestionLines, document, position, linePrefix, lineSuffix);
402+
403+
// TODO: this is disabled because it removes many useful suggestions
404+
//completion = this.updateSuggestion(suggestionLines, document, position, linePrefix, lineSuffix);
405+
403406
if (!isCachedResponse) this.lruResultCache.put(hashKey, completion)
404407
this.lastCompletion = this.getCompletionDetails(completion, position, inputPrefix, inputSuffix, prompt);
405408

@@ -443,7 +446,7 @@ export class Architect {
443446
this.updateStatusBarText();
444447
this.myStatusBarItem.show();
445448
}
446-
449+
447450
private registerEventListeners(context: vscode.ExtensionContext) {
448451
context.subscriptions.push(
449452
vscode.workspace.onDidChangeConfiguration(e => {
@@ -456,7 +459,7 @@ export class Architect {
456459
})
457460
);
458461
}
459-
462+
460463
private createMenuItems(currentLanguage: string | undefined, isLanguageEnabled: boolean): vscode.QuickPickItem[] {
461464
return [
462465
{
@@ -475,7 +478,7 @@ export class Architect {
475478
}
476479
].filter(Boolean) as vscode.QuickPickItem[];
477480
}
478-
481+
479482
private async handleMenuSelection(selected: vscode.QuickPickItem, currentLanguage: string | undefined, languageSettings: Record<string, boolean>) {
480483
switch (selected.label) {
481484
case "$(gear) Edit Settings...":
@@ -490,7 +493,7 @@ export class Architect {
490493
}
491494
this.updateStatusBarText();
492495
}
493-
496+
494497
private async handleCompletionToggle(label: string, currentLanguage: string | undefined, languageSettings: Record<string, boolean>) {
495498
const config = vscode.workspace.getConfiguration('llama-vscode');
496499
if (label.includes('All Completions')) {
@@ -501,13 +504,13 @@ export class Architect {
501504
await config.update('languageSettings', languageSettings, true);
502505
}
503506
}
504-
507+
505508
private updateStatusBarText() {
506509
const editor = vscode.window.activeTextEditor;
507510
const currentLanguage = editor?.document.languageId;
508511
const isEnabled = this.extConfig.enabled;
509512
const isLanguageEnabled = currentLanguage ? this.isCompletionEnabled(editor.document) : true;
510-
513+
511514
if (!isEnabled) {
512515
this.myStatusBarItem.text = "$(x) llama.vscode";
513516
} else if (currentLanguage && !isLanguageEnabled) {
@@ -519,14 +522,14 @@ export class Architect {
519522

520523
private isCompletionEnabled(document?: vscode.TextDocument, language?: string): boolean {
521524
if (!this.extConfig.enabled) return false;
522-
525+
523526
const languageToCheck = language ?? document?.languageId;
524527
if (languageToCheck) {
525528
const config = vscode.workspace.getConfiguration('llama-vscode');
526529
const languageSettings = config.get<Record<string, boolean>>('languageSettings') || {};
527530
return languageSettings[languageToCheck] ?? true;
528531
}
529-
532+
530533
return true;
531534
}
532535

@@ -688,7 +691,7 @@ export class Architect {
688691
let indLastSuggestionLine = suggestionLines.slice(1).reverse().findIndex((value, index) => value != document.lineAt((position.line + linesToCompareCount) - index).text)
689692
return suggestionLines.slice(0, indLastSuggestionLine + 2).join("\n"); // if indLastSuggestionLine is -1 then all following lines are the same as the suggestion
690693
}
691-
694+
692695
// if the following lines repeat the suggestion and the first line ends with the line suffix update suggestion
693696
if (suggestionLines.length > 1
694697
&& suggestionLines[0].endsWith(lineSuffix)

0 commit comments

Comments
 (0)