From 94ce25065bb709794904b8ee96c1144006520750 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 26 Dec 2022 14:04:46 +0800 Subject: [PATCH] fix(showcmd): assert failure with cmdheight=0 (#21536) --- src/nvim/normal.c | 3 +++ test/functional/ui/cmdline_spec.lua | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 1f7cc6c4f6..7979d2502e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1990,6 +1990,9 @@ static void display_showcmd(void) return; } // 'showcmdloc' is "last" or empty + if (p_ch == 0 && !ui_has(kUIMessages)) { + return; + } if (ui_has(kUIMessages)) { MAXSIZE_TEMP_ARRAY(content, 1); diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index c73c2d9f8a..1bdd55d66b 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1351,4 +1351,17 @@ describe('cmdheight=0', function() {1:~ }│{1:~ }| ]]) end) + + it('no assert failure with showcmd', function() + command('set showcmd cmdheight=0') + feed('d') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]) + assert_alive() + end) end)