From 2fc57ea57ece341a4f52e2de36beefd10ec68b1f Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 25 Jan 2024 20:09:34 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20default=20to=20first=20selected?= =?UTF-8?q?=20range=20with=20/edit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/commands/slash/edit.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/commands/slash/edit.ts b/core/commands/slash/edit.ts index b28f72511..e20cc922b 100644 --- a/core/commands/slash/edit.ts +++ b/core/commands/slash/edit.ts @@ -206,10 +206,15 @@ const EditSlashCommand: SlashCommand = { name: "edit", description: "Edit selected code", run: async function* ({ ide, llm, input, history, contextItems, params }) { - const contextItemToEdit = contextItems.find( + let contextItemToEdit = contextItems.find( (item: ContextItemWithId) => item.editing && item.id.providerTitle === "code" ); + if (!contextItemToEdit) { + contextItemToEdit = contextItems.find( + (item: ContextItemWithId) => item.id.providerTitle === "code" + ); + } if (!contextItemToEdit) { yield "Select (highlight and press `cmd+shift+M` (MacOS) / `ctrl+shift+M` (Windows)) the code that you want to edit first";