Description
When Diffview is configured with file_panel.show = false, opening a diff view starts with the file panel hidden, which is expected.
The problem appears when I later open the panel with :DiffviewToggleFiles: the cursor in the file panel is not placed on the currently diffed file entry. By contrast, when the panel is shown from the start, the cursor is correctly on the active file in the file panel.
This makes the hidden-by-default workflow feel inconsistent, because the panel no longer reflects the current diff selection when opened on demand.
Expected behavior
When file_panel.show = false and I open the panel later with :DiffviewToggleFiles, the file panel should place the cursor on the file that is currently being diffed, the same way it does when the panel is visible from initial view startup.
Actual behavior
With file_panel.show = false, after opening the panel via :DiffviewToggleFiles, the panel opens but the cursor is not automatically positioned on the currently diffed file entry.
If file_panel.show = true, the cursor is correctly on the active file entry when the view opens.
Steps to reproduce
- Save the minimal config below as
mini.lua.
- Run
nvim --clean -u mini.lua inside a git repository with at least a few changed files.
- Run
:DiffviewOpen.
- Observe that the file panel is hidden, as configured.
- Run
:DiffviewToggleFiles.
- Observe that the file panel opens, but the cursor is not positioned on the file currently shown in the diff.
- Change
file_panel.show to true in the same config and repeat.
- Observe that with the panel shown from startup, the cursor is on the currently diffed file entry.
Health check
Output of :checkhealth diffview
diffview: 4 ⚠️
Checking plugin dependencies ~
- ✅ OK nvim-web-devicons installed.
- ⚠️ WARNING Optional dependency 'mini.icons' not found.
Checking VCS tools ~
- The plugin requires at least one of the supported VCS tools to be valid.
- ⚠️ WARNING Configured `jj_cmd` is not executable: 'jj'
- ✅ OK Git found.
- ✅ OK Git is up-to-date. (2.50.1)
- ⚠️ WARNING Configured `hg_cmd` is not executable: 'hg'
- ⚠️ WARNING Configured `p4_cmd` is not executable: 'p4'##################
Log info
Relevant info from :DiffviewLog
############################
### PUT LOG CONTENT HERE ###
############################
Neovim version
NVIM v0.12.1
Build type: Release
Operating system and version
MacOS 15.7.4
Minimal config
local root = vim.fn.stdpath("run") .. "/nvim/diffview.nvim"
local plugin_dir = root .. "/plugins"
vim.fn.mkdir(plugin_dir, "p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local plugins = {
{ "nvim-web-devicons", url = "https://github.com/nvim-tree/nvim-web-devicons.git" },
{ "diffview.nvim", url = "https://github.com/dlyongemallo/diffview.nvim.git" },
}
for _, spec in ipairs(plugins) do
local install_path = plugin_dir .. "/" .. spec[1]
if vim.fn.isdirectory(install_path) ~= 1 then
if spec.url then
print(string.format("Installing '%s'...", spec[1]))
vim.fn.system({ "git", "clone", "--depth=1", spec.url, install_path })
end
end
vim.opt.runtimepath:append(spec.path or install_path)
end
require("diffview").setup({
file_panel = {
show = false,
},
})
vim.opt.termguicolors = true
vim.cmd("colorscheme habamax")
print("Ready!")
Description
When Diffview is configured with
file_panel.show = false, opening a diff view starts with the file panel hidden, which is expected.The problem appears when I later open the panel with
:DiffviewToggleFiles: the cursor in the file panel is not placed on the currently diffed file entry. By contrast, when the panel is shown from the start, the cursor is correctly on the active file in the file panel.This makes the hidden-by-default workflow feel inconsistent, because the panel no longer reflects the current diff selection when opened on demand.
Expected behavior
When
file_panel.show = falseand I open the panel later with:DiffviewToggleFiles, the file panel should place the cursor on the file that is currently being diffed, the same way it does when the panel is visible from initial view startup.Actual behavior
With
file_panel.show = false, after opening the panel via:DiffviewToggleFiles, the panel opens but the cursor is not automatically positioned on the currently diffed file entry.If
file_panel.show = true, the cursor is correctly on the active file entry when the view opens.Steps to reproduce
mini.lua.nvim --clean -u mini.luainside a git repository with at least a few changed files.:DiffviewOpen.:DiffviewToggleFiles.file_panel.showtotruein the same config and repeat.Health check
Output of
:checkhealth diffviewLog info
Relevant info from
:DiffviewLogNeovim version
Operating system and version
MacOS 15.7.4
Minimal config