diff --git a/clients/vscode/src/Commands.ts b/clients/vscode/src/Commands.ts index 994ab79ae36..896c9c23449 100644 --- a/clients/vscode/src/Commands.ts +++ b/clients/vscode/src/Commands.ts @@ -513,17 +513,26 @@ export class Commands { }, ); }, - "chat.edit.editNLOutline": async () => { + "chat.edit.editNLOutline": async (uri?: Uri, startLine?: number) => { const editor = window.activeTextEditor; if (!editor) return; - const position = editor.selection.active; - const line = position.line; - const content = this.nlOutlinesProvider.getOutline(editor.document.uri.toString(), line); + + let documentUri: string; + let line: number; + + if (uri && startLine !== undefined) { + documentUri = uri.toString(); + line = startLine; + } else { + documentUri = editor.document.uri.toString(); + line = editor.selection.active.line; + } + + const content = this.nlOutlinesProvider.getOutline(documentUri, line); getLogger().info("get content"); if (!content) return; - getLogger().info("shown"); - window.showInformationMessage(content); + const quickPick = window.createQuickPick(); quickPick.items = [{ label: content }]; quickPick.placeholder = "Edit NL Outline content"; @@ -532,14 +541,11 @@ export class Commands { quickPick.onDidAccept(async () => { const newContent = quickPick.value; quickPick.hide(); - - await this.nlOutlinesProvider.updateNLOutline(editor.document.uri.toString(), line, newContent); - + await this.nlOutlinesProvider.updateNLOutline(documentUri, line, newContent); window.showInformationMessage(`Updated NL Outline: ${newContent}`); }); quickPick.show(); - return; }, "chat.edit.stop": async () => { this.chatEditCancellationTokenSource?.cancel(); diff --git a/clients/vscode/src/NLOutlinesProvider.ts b/clients/vscode/src/NLOutlinesProvider.ts index ae7e814d4f3..44dfafbd9c5 100644 --- a/clients/vscode/src/NLOutlinesProvider.ts +++ b/clients/vscode/src/NLOutlinesProvider.ts @@ -224,8 +224,8 @@ export class NLOutlinesProvider extends EventEmitter implements CodeLensPr const editCommand: Command = { title: "Edit", - command: "extension.editOutline", - arguments: [document.uri, outline.startLine, outline.content], + command: "tabby.chat.edit.editNLOutline", + arguments: [document.uri, outline.startLine], }; const editCodeLens = new CodeLens(range, editCommand); @@ -259,9 +259,9 @@ export class NLOutlinesProvider extends EventEmitter implements CodeLensPr return this.outlines.get(documentUri)?.find((outline) => outline.startLine === lineNumber)?.content; } - //TODO: do diff when adding new code with old code, user should accpet or discard the new code; - //TODO: dynamic update remain outline or find a new way to show new code - //TODO: stream prompt new code not directly prompt everything + //TODO(Sma1lboy): do diff when adding new code with old code, user should accpet or discard the new code; + //TODO(Sma1lboy): dynamic update remain outline or find a new way to show new code + //TODO(Sma1lboy): stream prompt new code not directly prompt everything async updateNLOutline(documentUri: string, lineNumber: number, newContent: string) { const outlines = this.outlines.get(documentUri) || []; const oldOutlineIndex = outlines.findIndex((outline) => outline.startLine === lineNumber);