mirror of
https://github.com/neovim/neovim.git
synced 2025-10-09 19:36:40 +00:00
fix(statusline): don't leak memory with truncated click labels
This commit is contained in:
@@ -1987,6 +1987,11 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n
|
||||
// the truncation point
|
||||
for (int i = 0; i < itemcnt; i++) {
|
||||
if (stl_items[i].start > trunc_p) {
|
||||
for (int j = i; j < itemcnt; j++) {
|
||||
if (stl_items[j].type == ClickFunc) {
|
||||
XFREE_CLEAR(stl_items[j].cmd);
|
||||
}
|
||||
}
|
||||
itemcnt = i;
|
||||
break;
|
||||
}
|
||||
|
@@ -174,6 +174,14 @@ describe('statusline clicks', function()
|
||||
meths.input_mouse('right', 'press', '', 0, 6, 39)
|
||||
eq('0 1 r', eval("g:testvar"))
|
||||
end)
|
||||
|
||||
it('no memory leak with truncated click labels', function()
|
||||
command([[
|
||||
let &stl = '%@MyClickFunc@foo%X' .. repeat('a', 40) .. '%<t%@Test@bar%X%@Test@baz'
|
||||
]])
|
||||
meths.input_mouse('left', 'press', '', 0, 6, 2)
|
||||
eq('0 1 l', eval("g:testvar"))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('global statusline', function()
|
||||
|
Reference in New Issue
Block a user