Merge pull request #171 from kelly-lin/patch-1

Add support for deleting marks when multiselected by picker
This commit is contained in:
ThePrimeagen 2022-03-28 10:36:25 -06:00 committed by GitHub
commit a5a34f0d5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,7 +54,7 @@ end
local delete_harpoon_mark = function(prompt_bufnr)
local confirmation = vim.fn.input(
string.format("Delete current mark? [y/n]: ")
string.format("Delete current mark(s)? [y/n]: ")
)
if
string.len(confirmation) == 0
@ -63,20 +63,22 @@ local delete_harpoon_mark = function(prompt_bufnr)
print(string.format("Didn't delete mark"))
return
end
local selection = action_state.get_selected_entry()
harpoon_mark.rm_file(selection.filename)
local current_picker = action_state.get_current_picker(prompt_bufnr)
current_picker:refresh(generate_new_finder(), { reset_prompt = true })
end
local move_mark_up = function(prompt_bufnr)
local selection = action_state.get_selected_entry()
if harpoon_mark.get_length() == selection.index then
return
local function get_selections()
local results = {}
action_utils.map_selections(prompt_bufnr, function(entry)
table.insert(results, entry)
end)
return results
end
local mark_list = harpoon.get_mark_config().marks
table.remove(mark_list, selection.index)
table.insert(mark_list, selection.index + 1, selection.value)
local selections = get_selections()
for _, selection in ipairs(selections) do
harpoon_mark.rm_file(selection.filename)
end
local current_picker = action_state.get_current_picker(prompt_bufnr)
current_picker:refresh(generate_new_finder(), { reset_prompt = true })
end