Skip to content

Commit d46ebd2

Browse files
authored
fix(startup): avoid crash with completion from -l script (neovim#32160)
Related neovim#27764
1 parent a66f6ad commit d46ebd2

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/nvim/drawscreen.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,11 @@ bool default_grid_alloc(void)
177177
resizing = true;
178178

179179
// Allocation of the screen buffers is done only when the size changes and
180-
// when Rows and Columns have been set and we have started doing full
181-
// screen stuff.
180+
// when Rows and Columns have been set.
182181
if ((default_grid.chars != NULL
183182
&& Rows == default_grid.rows
184183
&& Columns == default_grid.cols)
185-
|| Rows == 0
186-
|| Columns == 0
187-
|| (!full_screen && default_grid.chars == NULL)) {
184+
|| Rows == 0 || Columns == 0) {
188185
resizing = false;
189186
return false;
190187
}

src/nvim/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ int main(int argc, char **argv)
360360

361361
setbuf(stdout, NULL); // NOLINT(bugprone-unsafe-functions)
362362

363-
full_screen = !silent_mode || exmode_active;
363+
full_screen = !silent_mode;
364364

365365
// Set the default values for the options that use Rows and Columns.
366366
win_init_size();

test/functional/core/main_spec.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,22 @@ describe('command-line option', function()
6767
eq(#'100500\n', attrs.size)
6868
end)
6969

70-
it('does not crash when run completion in Ex mode', function()
70+
it('does not crash when running completion in Ex mode', function()
7171
local p =
7272
n.spawn_wait('--clean', '-e', '-s', '--cmd', 'exe "norm! i\\<C-X>\\<C-V>"', '--cmd', 'qa!')
7373
eq(0, p.status)
7474
end)
7575

76+
it('does not crash when running completion from -l script', function()
77+
local lua_fname = 'Xinscompl.lua'
78+
write_file(lua_fname, [=[vim.cmd([[exe "norm! i\<C-X>\<C-V>"]])]=])
79+
finally(function()
80+
os.remove(lua_fname)
81+
end)
82+
local p = n.spawn_wait('--clean', '-l', lua_fname)
83+
eq(0, p.status)
84+
end)
85+
7686
it('does not crash after reading from stdin in non-headless mode', function()
7787
skip(is_os('win'))
7888
local screen = Screen.new(40, 8)

0 commit comments

Comments
 (0)