From aa2ea26bbd88739ac464d117c94c0ad477f5b39e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=A2=9A=E8=99=AB?= <123357481+5eqn@users.noreply.github.com> Date: Sat, 4 May 2024 01:15:38 +0800 Subject: [PATCH] :bug: fix undefined prefix, suffix and language for `/edit` (#1216) --- core/commands/slash/edit.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/commands/slash/edit.ts b/core/commands/slash/edit.ts index 38291f4c2..cac996f21 100644 --- a/core/commands/slash/edit.ts +++ b/core/commands/slash/edit.ts @@ -9,7 +9,7 @@ import { } from "../../autocomplete/lineStream"; import { streamLines } from "../../diff/util"; import { stripImages } from "../../llm/countTokens"; -import { dedentAndGetCommonWhitespace } from "../../util"; +import { dedentAndGetCommonWhitespace, getMarkdownLanguageTagForFile } from "../../util"; import { RangeInFileWithContents, contextItemToRangeInFileWithContents, @@ -456,6 +456,12 @@ const EditSlashCommand: SlashCommand = { userInput, filePrefix: filePrefix, fileSuffix: fileSuffix, + + // Some built-in templates use these instead of the above + prefix: filePrefix, + suffix: fileSuffix, + + language: getMarkdownLanguageTagForFile(rif.filepath), systemMessage: llm.systemMessage ?? "", // "contextItems": (await sdk.getContextItemChatMessages()).map(x => x.content || "").join("\n\n"), },