Skip to content

Commit 6978d34

Browse files
author
Farhan
committed
run before_change_callbacks on every operation
1 parent ffc3cd5 commit 6978d34

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lua/git-worktree/init.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ local function create_worktree(path, branch, upstream, found_branch)
394394
end
395395

396396
M.create_worktree = function(path, branch, upstream)
397-
status:reset(8)
397+
status:reset(9)
398+
399+
emit_before_change(Enum.Operations.Create, { path = path, prev_path = vim.loop.cwd() })
398400

399401
if upstream == nil then
400402
if has_origin() then
@@ -417,7 +419,10 @@ M.create_worktree = function(path, branch, upstream)
417419
end
418420

419421
M.switch_worktree = function(path)
420-
status:reset(2)
422+
status:reset(3)
423+
424+
emit_before_change(Enum.Operations.Switch, { path = path, prev_path = vim.loop.cwd() })
425+
421426
M.setup_git_info()
422427
has_worktree(path, function(found)
423428

@@ -438,7 +443,10 @@ M.delete_worktree = function(path, force, opts)
438443
opts = {}
439444
end
440445

441-
status:reset(2)
446+
status:reset(3)
447+
448+
emit_before_change(Enum.Operations.Delete, { path = vim.loop.cwd() })
449+
442450
M.setup_git_info()
443451
has_worktree(path, function(found)
444452
if not found then

0 commit comments

Comments
 (0)