fix(autocmd): guard number disable callback with is_disabled()#182
Open
snoblenet wants to merge 1 commit into
Open
fix(autocmd): guard number disable callback with is_disabled()#182snoblenet wants to merge 1 commit into
snoblenet wants to merge 1 commit into
Conversation
The BufLeave/WinLeave callback for config.ui.number unconditionally set vim.wo.number = false, unlike every sibling callback in this file (signcolumn, cursorline, cursorcolumn, colorcolumn, relativenumber, hybridnumber), which all check utils.is_disabled() first. This meant toggling vim.g.focus_disable mid-session still stripped line numbers from the window being left, instead of leaving it untouched like the other options. Add the same is_disabled() guard used elsewhere, and add a regression test in tests/test_ui.lua modeled on the existing signcolumn disable guard test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft PR for self-review -- NOT READY FOR PUBLIC REVIEW
======
The BufLeave/WinLeave callback for config.ui.number unconditionally set vim.wo.number = false, unlike every sibling callback in this file (signcolumn, cursorline, cursorcolumn, colorcolumn, relativenumber, hybridnumber), which all check utils.is_disabled() first. This meant toggling vim.g.focus_disable mid-session still stripped line numbers from the window being left, instead of leaving it untouched like the other options.
Add the same is_disabled() guard used elsewhere, and add a regression test in tests/test_ui.lua modeled on the existing signcolumn disable guard test.
Manual Testing
ui = { number = true }, open a file, and:vsplit.numberis on in the active split (:set number?).:let g:focus_disable = v:true.<C-w>w) — this firesWinLeaveon the window just left.numbershould still be on (unchanged), matching howsigncolumn/cursorline/etc. already behave when disabled. Before this fix,numberwould incorrectly turn off here.:let g:focus_disable = v:false, then move focus between the splits again and confirmnumberstill correctly follows focus (on in the active window, off in the inactive one) — normal behavior is unaffected.make test_file FILE=tests/test_ui.lua(all cases pass, including the newnumber respects disabled state on WinLeave).Checks
make test— passes (aside from one pre-existing, environment-specific failure intests/test_autoresize.luaunrelated to this change: sandbox denies spawning/bin/zshfor a terminal test)make test_file FILE=tests/test_ui.lua— passes, 15/15stylua --check .— passes, no formatting issuesmake lint(selene) — 16 pre-existing warnings (unused variables intests/test_functions.lua,tests/test_splits.lua,tests/test_ui.lua,tests/test_autoresize.lua, and vendoredtests/mini.test/), all predating this branch (blamed to a 2023 commit). No new warnings introduced by this change.