Explorer/history panel window options use :set semantics, so windows opened from the panel lose number/signcolumn/list
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- lua, neovim
- Domain
- developer-experience
Research direction
Start in lua/codediff/ui/lib/split.lua at Split:_apply_win_options(), which sets vim.wo[self.winid][k] without a scope, then look at apply_pane_options() in lua/codediff/ui/view/side_by_side/create.lua. Switch both to local-scope writes (vim.wo[winid][0][k]), reproduce with the nvim --clean command in the issue, and confirm that :tabnew g.py from the explorer keeps number and signcolumn set. Done means the inherited values stay at the user's settings while the panel still renders as before.
Written by the indexing model from the issue text.
Description
Summary
Windows created while the explorer (or history) panel is the current window inherit the panel's number=false, relativenumber=false, signcolumn=no, list=false, wrap=false, etc. For example, pressing :tabnew some/file.py or :vsplit with the cursor in the explorer opens a file with no line numbers and no sign column, even though the user's config has them on.
The reason is that the panel's win_options are applied with vim.wo[winid][k] = v, which has :set semantics (it updates both the window-local value and the window's "global" copy that new windows inherit). Applying them with :setlocal semantics (vim.wo[winid][0][k] = v, or nvim_set_option_value(k, v, { win = winid, scope = "local" })) keeps the panel's look while leaving the inherited values alone.
Environment
- codediff.nvim 4.0.6 (commit 09d9ebe)
- Neovim v0.12.6, macOS
Steps to reproduce
mkdir /tmp/cd-test && cd /tmp/cd-test && git init -q
printf 'a\n' > f.py; printf 'x\n' > g.py; git add .; git commit -qm init; echo b >> f.py
nvim --clean -c 'set number list signcolumn=yes' \
-c 'packadd codediff.nvim' -c 'lua require("codediff").setup()' \
-c 'CodeDiff' -c 'sleep 500m' \
-c 'lua vim.cmd("tabnew g.py"); print(("number=%s list=%s signcolumn=%s"):format(vim.wo.number, vim.wo.list, vim.wo.signcolumn))'
(Adjust packadd to however the plugin is installed; the behaviour is the same in a normal interactive session: :CodeDiff, then :tabnew g.py from the explorer.)
Observed: number=false list=false signcolumn=no
Expected: number=true list=true signcolumn=yes (the user's settings)
For comparison, doing the same from the nvim-tree window gives number=true list=true signcolumn=yes; nvim-tree applies its window options with nvim_set_option_value(k, v, { scope = "local" }).
Cause
lua/codediff/ui/lib/split.lua, Split:_apply_win_options():
for k, v in pairs(self._win_options) do
pcall(function()
vim.wo[self.winid][k] = v -- :set semantics
end)
end
Per :h vim.wo / :h nvim_set_option_value(), setting vim.wo[winid][k] without a buffer index behaves like :set in that window, so the window's inheritable copy of the option is overwritten too. New windows (:split, :vsplit, :tabnew, nvim_open_win) copy their options from the current window, so anything spawned from the panel starts with the panel's values.
The same pattern is used in apply_pane_options() in lua/codediff/ui/view/side_by_side/create.lua (vim.wo[original_win][opt] = val for cursorline, wrap, list). Because the explorer window is created while a diff pane is current, it inherits list=false from there, and then passes it on.
Suggested fix
Use :setlocal semantics in both places:
-- lib/split.lua
vim.wo[self.winid][0][k] = v
-- view/side_by_side/create.lua
vim.wo[original_win][0][opt] = val
vim.wo[modified_win][0][opt] = val
I verified the split.lua change by monkeypatching Split:_apply_win_options at runtime: the explorer still renders with number=false signcolumn=no, and :tabnew g.py from it now gives number=true signcolumn=yes (list stays false until apply_pane_options gets the same treatment).
Happy to open a PR if that is easier.
- Dominant language
- Lua
- Stars
- 1.6k
- Forks
- 104
- Avg merge
- 16d 23h
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from esmuellert/codediff.nvim
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
esmuellert/codediff.nvim#594 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
esmuellert/codediff.nvim#582 · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
esmuellert/codediff.nvim#575 ·
-
Bug: explorer.focus_on_select = false ignored for added/untracked/deleted files in inline layoutOpenType/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
esmuellert/codediff.nvim#567 · 1 reaction ·
-
Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
esmuellert/codediff.nvim#565 · 1 comment ·
All issues in esmuellert/codediff.nvim
Similar issues
-
bug discord triage
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
AndyHazz/bookends.koplugin#134 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
coolsnowwolf/lede#14305 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100