From c4dbc24916caed1d7f6c96a8925e8d6b7220fd9f Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Tue, 8 Sep 2026 23:24:33 +1000 Subject: [PATCH] test(nvim): cover nested worktree resolution --- .config/nvim/tests/worktree_spec.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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')