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";