Skip to content

Commit 53d5864

Browse files
committed
test(renderer): make eventignorewin handling robust across Neovim versions
Probe 'eventignorewin' with pcall and record presence in has_eventignorewin. Only restore and assert the window-local option when it exists to avoid failures on Neovim builds that don't expose 'eventignorewin'. Add explanatory comments and a small refactor in tests/unit/output_window_spec.lua.
1 parent 837a11d commit 53d5864

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

tests/unit/output_window_spec.lua

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ describe('renderer flush cleanup', function()
187187
local win
188188
local original_eventignore
189189
local original_eventignorewin
190+
local has_eventignorewin
190191
local begin_update_stub
191192
local end_update_stub
192193
local set_lines_stub
@@ -203,7 +204,10 @@ describe('renderer flush cleanup', function()
203204
})
204205
state.ui.set_windows({ output_buf = buf, output_win = win })
205206
original_eventignore = vim.o.eventignore
206-
original_eventignorewin = vim.api.nvim_get_option_value('eventignorewin', { win = win })
207+
-- 'eventignorewin' may not exist on older/newer Neovim versions; probe safely
208+
local ok, val = pcall(vim.api.nvim_get_option_value, 'eventignorewin', { win = win })
209+
has_eventignorewin = ok
210+
original_eventignorewin = ok and val or nil
207211
begin_update_stub = stub(output_window, 'begin_update').returns(true)
208212
end_update_stub = stub(output_window, 'end_update')
209213
set_lines_stub = stub(output_window, 'set_lines').invokes(function()
@@ -226,7 +230,8 @@ describe('renderer flush cleanup', function()
226230
begin_update_stub:revert()
227231
end
228232
vim.o.eventignore = original_eventignore
229-
if win and vim.api.nvim_win_is_valid(win) then
233+
if win and vim.api.nvim_win_is_valid(win) and has_eventignorewin then
234+
-- only restore if the option exists on this Neovim build
230235
vim.api.nvim_set_option_value('eventignorewin', original_eventignorewin, { win = win, scope = 'local' })
231236
end
232237
state.ui.set_windows(nil)
@@ -244,7 +249,9 @@ describe('renderer flush cleanup', function()
244249
assert.is_false(ok)
245250
assert.matches('boom', err)
246251
assert.equals(original_eventignore, vim.o.eventignore)
247-
assert.equals(original_eventignorewin, vim.api.nvim_get_option_value('eventignorewin', { win = win }))
252+
if has_eventignorewin then
253+
assert.equals(original_eventignorewin, vim.api.nvim_get_option_value('eventignorewin', { win = win }))
254+
end
248255
assert.stub(begin_update_stub).was_called(1)
249256
assert.stub(end_update_stub).was_called(1)
250257
assert.is_false(ctx.bulk_mode)

0 commit comments

Comments
 (0)