Skip to content

Commit

Permalink
delete visual selection in ChatFinder
Browse files Browse the repository at this point in the history
  • Loading branch information
LLMChild committed Sep 20, 2024
1 parent 2372d53 commit 2d69ce7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions lua/gp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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! \<ESC>"]])
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()
Expand Down

0 comments on commit 2d69ce7

Please sign in to comment.