Skip to content

Commit 431004d

Browse files
authored
fix: screenchar()/screenstring() with hidden floating windows neovim#35560
1 parent 79bfeec commit 431004d

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/nvim/ui_compositor.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ ScreenGrid *ui_comp_get_grid_at_coord(int row, int col)
335335
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
336336
ScreenGrid *grid = &wp->w_grid_alloc;
337337
if (row >= grid->comp_row && row < grid->comp_row + grid->rows
338-
&& col >= grid->comp_col && col < grid->comp_col + grid->cols) {
338+
&& col >= grid->comp_col && col < grid->comp_col + grid->cols
339+
&& !wp->w_config.hide) {
339340
return grid;
340341
}
341342
}

test/functional/vimscript/screenchar_spec.lua

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,39 @@ describe('screenchar() and family respect floating windows', function()
7676
describe('with ext_multigrid', function()
7777
with_ext_multigrid(true)
7878
end)
79+
7980
describe('without ext_multigrid', function()
8081
with_ext_multigrid(false)
8182
end)
83+
84+
describe('hidden windows', function()
85+
before_each(function()
86+
clear()
87+
Screen.new(40, 7, {})
88+
api.nvim_buf_set_lines(0, 0, -1, true, { 'aaa', 'aaa' })
89+
end)
90+
91+
local assert_screen_funcs = function()
92+
eq('a', fn.screenstring(1, 1))
93+
eq(97, fn.screenchar(1, 1))
94+
eq({ 97 }, fn.screenchars(1, 1))
95+
eq(fn.screenattr(2, 1), fn.screenattr(1, 1))
96+
end
97+
98+
it('manual', function()
99+
local bufnr = api.nvim_create_buf(false, true)
100+
api.nvim_buf_set_lines(bufnr, 0, -1, true, { 'bb' })
101+
local win_opts = { relative = 'editor', row = 0, col = 0, height = 1, width = 2, hide = true }
102+
api.nvim_open_win(bufnr, false, win_opts)
103+
104+
assert_screen_funcs()
105+
end)
106+
107+
it('from ui2', function()
108+
n.exec_lua('require("vim._extui").enable({ enable = true })')
109+
command('echo "foo"')
110+
111+
assert_screen_funcs()
112+
end)
113+
end)
82114
end)

0 commit comments

Comments
 (0)