mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-13 17:40:25 +00:00
Merge pull request #171 from kelly-lin/patch-1
Add support for deleting marks when multiselected by picker
This commit is contained in:
commit
a5a34f0d5d
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user