@@ -9,6 +9,7 @@ local conf = require('telescope.config').values
99local git_worktree = require (' git-worktree' )
1010local Config = require (' git-worktree.config' )
1111local Git = require (' git-worktree.git' )
12+ local Log = require (' git-worktree.logger' )
1213
1314local force_next_deletion = false
1415
@@ -93,6 +94,9 @@ local delete_success_handler = function(opts)
9394 if confirm_branch_deletion () and opts .branch ~= nil then
9495 local delete_branch_job = Git .delete_branch_job (opts .branch )
9596 if delete_branch_job ~= nil then
97+ delete_branch_job :after_success (vim .schedule_wrap (function ()
98+ print (' Branch deleted' )
99+ end ))
96100 delete_branch_job :start ()
97101 end
98102 end
@@ -133,6 +137,15 @@ local create_input_prompt = function(opts, cb)
133137 opts .pattern = nil -- show all branches that can be tracked
134138
135139 local path = vim .fn .input (' Path to subtree > ' , opts .branch )
140+ if path == ' ' then
141+ Log .error (" No worktree path provided" )
142+ return
143+ end
144+
145+ if opts .branch == ' ' then
146+ cb (path , nil )
147+ return
148+ end
136149
137150 local branches = vim .fn .systemlist (' git branch --all' )
138151 if # branches == 0 then
@@ -172,17 +185,11 @@ local telescope_create_worktree = function(opts)
172185 git_worktree .switch_worktree (nil )
173186 opts = opts or {}
174187
175- -- TODO: Enable detached HEAD worktree creation, but for this the telescope
176- -- picker git_branches must show refs/tags.
177-
178188 local create_branch = function (prompt_bufnr , _ )
179189 -- if current_line is still not enough to filter everything but user
180190 -- still wants to use it as the new branch name, without selecting anything
181191 local branch = action_state .get_current_line ()
182192 actions .close (prompt_bufnr )
183- if branch == nil then
184- return
185- end
186193 opts .branch = branch
187194 create_input_prompt (opts , function (path , upstream )
188195 git_worktree .create_worktree (path , branch , upstream )
@@ -196,7 +203,8 @@ local telescope_create_worktree = function(opts)
196203 -- selected_entry can be null if current_line filters everything
197204 -- and there's no branch shown
198205 local branch = selected_entry ~= nil and selected_entry .value or current_line
199- if branch == nil then
206+ if branch == nil or branch == ' ' then
207+ Log .error (" No branch selected" )
200208 return
201209 end
202210 opts .branch = branch
0 commit comments