From ae180c6d16b05c533c53cb77004d42b8b8488aee Mon Sep 17 00:00:00 2001 From: 5eqn <491100866@qq.com> Date: Mon, 6 May 2024 08:35:37 +0800 Subject: [PATCH 1/2] :bug: fix #1237 --- core/commands/slash/edit.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/core/commands/slash/edit.ts b/core/commands/slash/edit.ts index cac996f21..4dd3e9d0d 100644 --- a/core/commands/slash/edit.ts +++ b/core/commands/slash/edit.ts @@ -9,7 +9,10 @@ import { } from "../../autocomplete/lineStream"; import { streamLines } from "../../diff/util"; import { stripImages } from "../../llm/countTokens"; -import { dedentAndGetCommonWhitespace, getMarkdownLanguageTagForFile } from "../../util"; +import { + dedentAndGetCommonWhitespace, + getMarkdownLanguageTagForFile, +} from "../../util"; import { RangeInFileWithContents, contextItemToRangeInFileWithContents, @@ -231,14 +234,7 @@ const EditSlashCommand: SlashCommand = { } // Strip unecessary parts of the input (the fact that you have to do this is suboptimal, should be refactored away) - let content = history[history.length - 1].content; - if (typeof content !== "string") { - content.forEach((part) => { - if (part.text && part.text.startsWith("/edit")) { - part.text = part.text.replace("/edit", "").trimStart(); - } - }); - } + let content = input.replace("/edit", "").trimStart(); let userInput = stripImages(content).replace( `\`\`\`${contextItemToEdit.name}\n${contextItemToEdit.content}\n\`\`\`\n`, "", From 0c642b1b8b26f0e8101130068028696a033d827d Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sun, 5 May 2024 23:25:40 -0700 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20fix=20content=20parsing=20re?= =?UTF-8?q?gression=20in=20/edit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/commands/slash/edit.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/commands/slash/edit.ts b/core/commands/slash/edit.ts index 4dd3e9d0d..3ec1cb2f2 100644 --- a/core/commands/slash/edit.ts +++ b/core/commands/slash/edit.ts @@ -234,7 +234,16 @@ const EditSlashCommand: SlashCommand = { } // Strip unecessary parts of the input (the fact that you have to do this is suboptimal, should be refactored away) - let content = input.replace("/edit", "").trimStart(); + let content = history[history.length - 1].content; + if (typeof content !== "string") { + content.forEach((part) => { + if (part.text && part.text.startsWith("/edit")) { + part.text = part.text.replace("/edit", "").trimStart(); + } + }); + } else { + content = input.replace("/edit", "").trimStart(); + } let userInput = stripImages(content).replace( `\`\`\`${contextItemToEdit.name}\n${contextItemToEdit.content}\n\`\`\`\n`, "",