aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2018-02-13 19:47:27 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2018-02-14 19:20:28 +0100
commitd9497053e84aaf3dabecd362da19913811e8c22e (patch)
tree940693dfcfeeeaa3bc62c88b9277d0bec877893e
parent0f1bc5ddceb50ca8f96d91aabf8157d9758af0cd (diff)
downloadrneovim-d9497053e84aaf3dabecd362da19913811e8c22e.tar.gz
rneovim-d9497053e84aaf3dabecd362da19913811e8c22e.tar.bz2
rneovim-d9497053e84aaf3dabecd362da19913811e8c22e.zip
ex_getln: clear cmdline_block after it's freed
-rw-r--r--src/nvim/ex_getln.c4
-rw-r--r--test/functional/ui/cmdline_spec.lua29
2 files changed, 32 insertions, 1 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 07aab3307a..dd7504c05e 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -194,7 +194,8 @@ static int cmd_showtail; /* Only show path tail in lists ? */
static int new_cmdpos; /* position set by set_cmdline_pos() */
-static Array cmdline_block; ///< currently displayed block of context
+/// currently displayed block of context
+static Array cmdline_block = ARRAY_DICT_INIT;
/*
* Type used by call_user_expand_func
@@ -2990,6 +2991,7 @@ void ui_ext_cmdline_block_append(int indent, const char *line)
void ui_ext_cmdline_block_leave(void)
{
api_free_array(cmdline_block);
+ cmdline_block = (Array)ARRAY_DICT_INIT;
ui_call_cmdline_block_hide();
}
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua
index d15afc81bb..f8680678ef 100644
--- a/test/functional/ui/cmdline_spec.lua
+++ b/test/functional/ui/cmdline_spec.lua
@@ -348,6 +348,35 @@ describe('external cmdline', function()
{ { {}, ' line1'} } }, block)
end)
+ feed('endfunction<cr>')
+ screen:expect([[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]], nil, nil, function()
+ eq(nil, block)
+ end)
+
+ -- Try once more, to check buffer is reinitialized. #8007
+ feed(':function Bar()<cr>')
+ screen:expect([[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]], nil, nil, function()
+ eq({{
+ content = { { {}, "" } },
+ firstc = ":",
+ indent = 2,
+ pos = 0,
+ prompt = "",
+ }}, cmdline)
+ eq({ { { {}, 'function Bar()'} } }, block)
+ end)
feed('endfunction<cr>')
screen:expect([[