Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make delete shortcut can delete visual selection in ChatFinder #213

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lua/gp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,25 @@ 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]
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]

Expand Down
Loading