Skip to content

Commit 30ea5db

Browse files
committed
fix(renderer/flush): guard 'eventignorewin' usage on older Neovim
Use pcall to probe for support of the 'eventignorewin' option and only set/restore it when available. Prevents runtime errors on older Neovim versions (e.g. in CI) while keeping the output window update logic intact.
1 parent 0556f70 commit 30ea5db

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

lua/opencode/ui/renderer/flush.lua

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,23 @@ local M = {}
1212
local function with_suppressed_output_autocmds(fn)
1313
local output_win = state.windows and state.windows.output_win
1414
local has_output_win = output_win and vim.api.nvim_win_is_valid(output_win)
15-
local saved_eventignorewin = has_output_win and vim.api.nvim_get_option_value('eventignorewin', { win = output_win })
16-
or nil
17-
15+
-- 'eventignorewin' is not available in all Neovim versions. Use pcall to
16+
-- detect support and avoid throwing an error on older versions used in CI.
17+
local supports_eventignorewin = false
18+
local saved_eventignorewin = nil
1819
if has_output_win then
19-
vim.api.nvim_set_option_value('eventignorewin', 'all', { win = output_win, scope = 'local' })
20+
local ok, val = pcall(vim.api.nvim_get_option_value, 'eventignorewin', { win = output_win })
21+
if ok then
22+
supports_eventignorewin = true
23+
saved_eventignorewin = val
24+
pcall(vim.api.nvim_set_option_value, 'eventignorewin', 'all', { win = output_win, scope = 'local' })
25+
end
2026
end
2127

2228
local begin_ok, began_update = xpcall(output_window.begin_update, debug.traceback)
2329
if not begin_ok then
24-
if has_output_win then
25-
vim.api.nvim_set_option_value('eventignorewin', saved_eventignorewin, { win = output_win, scope = 'local' })
30+
if has_output_win and supports_eventignorewin then
31+
pcall(vim.api.nvim_set_option_value, 'eventignorewin', saved_eventignorewin, { win = output_win, scope = 'local' })
2632
end
2733
error(began_update)
2834
end
@@ -33,8 +39,8 @@ local function with_suppressed_output_autocmds(fn)
3339
if began_update then
3440
end_ok, end_err = xpcall(output_window.end_update, debug.traceback)
3541
end
36-
if has_output_win then
37-
vim.api.nvim_set_option_value('eventignorewin', saved_eventignorewin, { win = output_win, scope = 'local' })
42+
if has_output_win and supports_eventignorewin then
43+
pcall(vim.api.nvim_set_option_value, 'eventignorewin', saved_eventignorewin, { win = output_win, scope = 'local' })
3844
end
3945

4046
if not ok then

0 commit comments

Comments
 (0)