Skip to content

Commit

Permalink
run before_change_callbacks on every operation
Browse files Browse the repository at this point in the history
  • Loading branch information
ngntrpy committed Oct 31, 2023
1 parent ffc3cd5 commit 6978d34
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lua/git-worktree/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,9 @@ local function create_worktree(path, branch, upstream, found_branch)
end

M.create_worktree = function(path, branch, upstream)
status:reset(8)
status:reset(9)

emit_before_change(Enum.Operations.Create, { path = path, prev_path = vim.loop.cwd() })

if upstream == nil then
if has_origin() then
Expand All @@ -417,7 +419,10 @@ M.create_worktree = function(path, branch, upstream)
end

M.switch_worktree = function(path)
status:reset(2)
status:reset(3)

emit_before_change(Enum.Operations.Switch, { path = path, prev_path = vim.loop.cwd() })

M.setup_git_info()
has_worktree(path, function(found)

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

status:reset(2)
status:reset(3)

emit_before_change(Enum.Operations.Delete, { path = vim.loop.cwd() })

M.setup_git_info()
has_worktree(path, function(found)
if not found then
Expand Down

0 comments on commit 6978d34

Please sign in to comment.