Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lua/focus/modules/autocmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ function M.setup(config)
vim.api.nvim_create_autocmd({ 'BufLeave', 'WinLeave' }, {
group = augroup,
callback = function(_)
if utils.is_disabled() then
return
end
vim.wo.number = false
end,
desc = 'Disable cursorline',
Expand Down
32 changes: 32 additions & 0 deletions tests/test_ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,38 @@ T['focus_ui']['signcolumn respects disabled state on WinLeave'] = function()
)
end

T['focus_ui']['number respects disabled state on WinLeave'] = function()
reload_module({ ui = { number = true } })
edit(lorem_ipsum_file)
child.set_cursor(15, 0)
child.cmd('vsplit')

local resize_state = child.get_resize_state()
local win_id_left = resize_state.windows[1]
local win_id_right = resize_state.windows[2]

eq(win_id_left, child.api.nvim_get_current_win())
eq(child.wo.number, true)

-- Disable focus.nvim
child.lua('vim.g.focus_disable = true')

-- Switch to the other window (triggers WinLeave on current window)
child.api.nvim_set_current_win(win_id_right)

-- Helper to get number option from specific window
child.lua([[_G.win_get_number = function(winid)
local win_number = false
vim.api.nvim_win_call(winid, function()
win_number = vim.wo.number
end)
return win_number
end]])

-- The left window's number should still be true because focus is disabled
eq(child.lua_get(string.format('_G.win_get_number(%d)', win_id_left)), true)
end

T['focus_ui']['cursorcolumn with split'] = function()
reload_module({ ui = { cursorcolumn = true } })
edit(lorem_ipsum_file)
Expand Down