From 2d69ce7095c702753c6d42c90ad4ddc5856be7e9 Mon Sep 17 00:00:00 2001 From: LLMChild <2803354011@qq.com> Date: Fri, 20 Sep 2024 14:18:48 +0800 Subject: [PATCH] delete visual selection in ChatFinder --- lua/gp/init.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lua/gp/init.lua b/lua/gp/init.lua index 128914c..593a11a 100644 --- a/lua/gp/init.lua +++ b/lua/gp/init.lua @@ -1461,10 +1461,28 @@ M.cmd.ChatFinder = function() delete_shortcut.modes, delete_shortcut.shortcut, function() + local mode = vim.api.nvim_get_mode().mode + if mode == "v" then + -- get visual selection + vim.cmd([[execute "normal! \"]]) + local line1 = vim.api.nvim_buf_get_mark(0, "<")[1] + local line2 = vim.api.nvim_buf_get_mark(0, ">")[1] + vim.g.lines = { line1, line2 } + if line1 == line2 then + M.helpers.delete_file(picker_files[line1]) + return + end + for i = line1, line2 do + local file = picker_files[i] + if file then + M.helpers.delete_file(file) + end + end + refresh_picker() + return + end -- delete without confirmation local index = vim.api.nvim_win_get_cursor(picker_win)[1] local file = picker_files[index] - - -- delete without confirmation if not M.config.chat_confirm_delete then M.helpers.delete_file(file) refresh_picker()