From b21d960119344b19f8cec64f8e9d56bfa9cdce85 Mon Sep 17 00:00:00 2001 From: glepnir Date: Thu, 7 Mar 2024 18:12:57 +0800 Subject: fix(startup): set full_screen when in ex_mode Problem Description: In ex_mode, the default_grid.chars are not allocated, and subsequently, the w_grid.target in curwin is not allocated to default_grid in update_screen. This leads to a null pointer crash when the completion function is executed in ex_mode. Solution: Set full_screen when in ex_mode to ensure that default_grid is allocated. --- src/nvim/main.c | 2 +- test/functional/core/main_spec.lua | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/nvim/main.c b/src/nvim/main.c index 6b8c8253dc..ea189aaa0c 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -363,7 +363,7 @@ int main(int argc, char **argv) setbuf(stdout, NULL); // NOLINT(bugprone-unsafe-functions) - full_screen = !silent_mode; + full_screen = !silent_mode || exmode_active; // Set the default values for the options that use Rows and Columns. win_init_size(); diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua index 1d2261ee05..9d8d64c82d 100644 --- a/test/functional/core/main_spec.lua +++ b/test/functional/core/main_spec.lua @@ -73,6 +73,18 @@ describe('command-line option', function() eq(#'100500\n', attrs.size) end) + it('does not crash when run completion in ex mode', function() + fn.system({ + nvim_prog_abs(), + '--clean', + '-e', + '-s', + '--cmd', + 'exe "norm! i\\\\"', + }) + eq(0, eval('v:shell_error')) + end) + it('does not crash after reading from stdin in non-headless mode', function() skip(is_os('win')) local screen = Screen.new(40, 8) -- cgit