Skip to content

fix(autocmd): guard number disable callback with is_disabled()#182

Open
snoblenet wants to merge 1 commit into
nvim-focus:masterfrom
snoblenet:fix-number-focus-disable-guard
Open

fix(autocmd): guard number disable callback with is_disabled()#182
snoblenet wants to merge 1 commit into
nvim-focus:masterfrom
snoblenet:fix-number-focus-disable-guard

Conversation

@snoblenet

@snoblenet snoblenet commented Jul 9, 2026

Copy link
Copy Markdown

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

  1. Configure focus.nvim with ui = { number = true }, open a file, and :vsplit.
  2. Confirm number is on in the active split (:set number?).
  3. Disable focus.nvim mid-session: :let g:focus_disable = v:true.
  4. Move focus to the other split (<C-w>w) — this fires WinLeave on the window just left.
  5. Check the window just left: number should still be on (unchanged), matching how signcolumn/cursorline/etc. already behave when disabled. Before this fix, number would incorrectly turn off here.
  6. Re-enable focus.nvim: :let g:focus_disable = v:false, then move focus between the splits again and confirm number still correctly follows focus (on in the active window, off in the inactive one) — normal behavior is unaffected.
  7. Cross-check with the automated regression test: make test_file FILE=tests/test_ui.lua (all cases pass, including the new number respects disabled state on WinLeave).

Checks

  • make test — passes (aside from one pre-existing, environment-specific failure in tests/test_autoresize.lua unrelated to this change: sandbox denies spawning /bin/zsh for a terminal test)
  • make test_file FILE=tests/test_ui.lua — passes, 15/15
  • stylua --check . — passes, no formatting issues
  • make lint (selene) — 16 pre-existing warnings (unused variables in tests/test_functions.lua, tests/test_splits.lua, tests/test_ui.lua, tests/test_autoresize.lua, and vendored tests/mini.test/), all predating this branch (blamed to a 2023 commit). No new warnings introduced by this change.

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.
@snoblenet snoblenet marked this pull request as ready for review July 10, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant