Skip to content

Commit 2d69ce7

Browse files
committed
delete visual selection in ChatFinder
1 parent 2372d53 commit 2d69ce7

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lua/gp/init.lua

+20-2
Original file line numberDiff line numberDiff line change
@@ -1461,10 +1461,28 @@ M.cmd.ChatFinder = function()
14611461
delete_shortcut.modes,
14621462
delete_shortcut.shortcut,
14631463
function()
1464+
local mode = vim.api.nvim_get_mode().mode
1465+
if mode == "v" then
1466+
-- get visual selection
1467+
vim.cmd([[execute "normal! \<ESC>"]])
1468+
local line1 = vim.api.nvim_buf_get_mark(0, "<")[1]
1469+
local line2 = vim.api.nvim_buf_get_mark(0, ">")[1]
1470+
vim.g.lines = { line1, line2 }
1471+
if line1 == line2 then
1472+
M.helpers.delete_file(picker_files[line1])
1473+
return
1474+
end
1475+
for i = line1, line2 do
1476+
local file = picker_files[i]
1477+
if file then
1478+
M.helpers.delete_file(file)
1479+
end
1480+
end
1481+
refresh_picker()
1482+
return
1483+
end -- delete without confirmation
14641484
local index = vim.api.nvim_win_get_cursor(picker_win)[1]
14651485
local file = picker_files[index]
1466-
1467-
-- delete without confirmation
14681486
if not M.config.chat_confirm_delete then
14691487
M.helpers.delete_file(file)
14701488
refresh_picker()

0 commit comments

Comments
 (0)