🩹 default to first selected range with /edit

This commit is contained in:
Nate Sesti 2024-01-25 20:09:34 -08:00
parent 8375ee3271
commit 2fc57ea57e

View file

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