diff --git a/.config/nvim/tests/worktree_spec.lua b/.config/nvim/tests/worktree_spec.lua index ffbf9f7..5d0bc2f 100644 --- a/.config/nvim/tests/worktree_spec.lua +++ b/.config/nvim/tests/worktree_spec.lua @@ -245,6 +245,19 @@ describe('func.worktree', function() assert.same({ 2, 1 }, worktree.clamp_cursor(buf, { 2, 1 })) end) + it('carries a buffer from the innermost worktree containing it', function() + local nested = main .. '/nested' + sh({ 'git', '-C', main, 'worktree', 'add', '-q', '-b', 'nested', nested }) + open(nested .. '/one.txt') + + local summary = worktree.switch(other) + + assert.is_not_nil(summary) + assert.same({ 'one.txt' }, summary.moved) + assert.same({}, summary.missing) + assert.equals(realpath(other) .. '/one.txt', vim.api.nvim_buf_get_name(vim.fn.bufnr(realpath(other) .. '/one.txt'))) + end) + it('lands on a valid line when the destination file is empty', function() vim.fn.writefile({}, other .. '/one.txt') open(main .. '/one.txt')