Repository: neovim/neovim
File: test/functional/plugin/difftool_spec.lua (Lua)

Code before:
    end

    -- Should show:
    -- file1.txt as modified (M)
    -- file2.txt as deleted (D)
    -- file3.txt as added (A)
    eq({
      { text = 'M', rel = 'file1.txt' },
      { text = 'D', rel = 'file2.txt' },
      { text = 'A', rel = 'file3.txt' },
    }, entries)
  end)

  it('has consistent split layout', function()
    command('set nosplitright')
    command(('DiffTool %s %s'):format(testdir_left, testdir_right))
    local wins = fn.getwininfo()
    local left_win_col = wins[1].wincol
    local right_win_col = wins[2].wincol
    assert(
      left_win_col < right_win_col,
      'Left window should be to the left of right window even with nosplitright set'
    )
  end)

  it('handles symlinks correctly', function()
    if t.is_os('win') then
      pending('Symlink test skipped on Windows')
      return
    end

    -- Create a symlink in right dir pointing to file2.txt in left dir
    local symlink_path = vim.fs.joinpath(testdir_right, 'file2.txt')
    local target_path = '../' .. vim.fs.joinpath(testdir_left, 'file2.txt')
    assert(os.execute(('ln -s %s %s'):format(target_path, symlink_path)) == 0)
    finally(function()
      os.remove(symlink_path)
    end)
    assert(fn.getftype(symlink_path) == 'link')

    -- Run difftool
    command(('DiffTool %s %s'):format(testdir_left, testdir_right))
    local qflist = fn.getqflist()
    local entries = {}
    for _, item in ipairs(qflist) do
      table.insert(entries, { text = item.text, rel = item.user_data and item.user_data.rel })
    end

    -- file2.txt should not be reported as added or deleted anymore
    eq({
      { text = 'M', rel = 'file1.txt' },

Review comment (suggestion):
```suggestion
  it('handles symlinks', function()
```

Code after:
    end

    -- Should show:
    -- file1.txt as modified (M)
    -- file2.txt as deleted (D)
    -- file3.txt as added (A)
    eq({
      { text = 'M', rel = 'file1.txt' },
      { text = 'D', rel = 'file2.txt' },
      { text = 'A', rel = 'file3.txt' },
    }, entries)
  end)

  it('has consistent split layout', function()
    command('set nosplitright')
    command(('DiffTool %s %s'):format(testdir_left, testdir_right))
    local wins = fn.getwininfo()
    local left_win_col = wins[1].wincol
    local right_win_col = wins[2].wincol
    assert(
      left_win_col < right_win_col,
      'Left window should be to the left of right window even with nosplitright set'
    )
  end)

  it('handles symlinks', function()
    -- Create a symlink in right dir pointing to file2.txt in left dir
    local symlink_path = vim.fs.joinpath(testdir_right, 'file2.txt')
    local target_path = vim.fs.joinpath('..', testdir_left, 'file2.txt')
    assert(vim.uv.fs_symlink(target_path, symlink_path) == true)
    finally(function()
      os.remove(symlink_path)
    end)
    assert(fn.getftype(symlink_path) == 'link')

    -- Run difftool
    command(('DiffTool %s %s'):format(testdir_left, testdir_right))
    local qflist = fn.getqflist()
    local entries = {}
    for _, item in ipairs(qflist) do
      table.insert(entries, { text = item.text, rel = item.user_data and item.user_data.rel })
    end

    -- file2.txt should not be reported as added or deleted anymore
    eq({
      { text = 'M', rel = 'file1.txt' },
      { text = 'A', rel = 'file3.txt' },
    }, entries)
  end)

  it('has autocmds when diff window is opened', function()