Skip to content
Closed
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
17 changes: 10 additions & 7 deletions lua/telescope/_extensions/git_worktree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ local git_worktree = require("git-worktree")

local force_next_deletion = false

local wt_actions = {}

local get_worktree_path = function(prompt_bufnr)
local selection = action_state.get_selected_entry(prompt_bufnr)
return selection.path
Expand All @@ -25,7 +27,7 @@ local switch_worktree = function(prompt_bufnr)
end
end

local toggle_forced_deletion = function()
wt_actions.toggle_forced_deletion = function()
-- redraw otherwise the message is not displayed when in insert mode
if force_next_deletion then
print('The next deletion will not be forced')
Expand Down Expand Up @@ -68,7 +70,7 @@ local confirm_deletion = function(forcing)
return false
end

local delete_worktree = function(prompt_bufnr)
wt_actions.delete_worktree = function(prompt_bufnr)
if not confirm_deletion() then
return
end
Expand Down Expand Up @@ -215,10 +217,10 @@ local telescope_git_worktree = function(opts)
attach_mappings = function(_, map)
action_set.select:replace(switch_worktree)

map("i", "<c-d>", delete_worktree)
map("n", "<c-d>", delete_worktree)
map("i", "<c-f>", toggle_forced_deletion)
map("n", "<c-f>", toggle_forced_deletion)
map("i", "<c-d>", wt_actions.delete_worktree)
map("n", "<c-d>", wt_actions.delete_worktree)
map("i", "<c-f>", wt_actions.toggle_forced_deletion)
map("n", "<c-f>", wt_actions.toggle_forced_deletion)

return true
end
Expand All @@ -229,6 +231,7 @@ return require("telescope").register_extension(
{
exports = {
git_worktrees = telescope_git_worktree,
create_git_worktree = create_worktree
create_git_worktree = create_worktree,
actions = wt_actions
}
})