mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix(sign): avoid deleting from sign map while looping over it (#27158)
This commit is contained in:
@@ -1021,9 +1021,14 @@ static void sign_get_placed(buf_T *buf, linenr_T lnum, int id, const char *group
|
|||||||
void free_signs(void)
|
void free_signs(void)
|
||||||
{
|
{
|
||||||
cstr_t name;
|
cstr_t name;
|
||||||
|
kvec_t(cstr_t) names = KV_INITIAL_VALUE;
|
||||||
map_foreach_key(&sign_map, name, {
|
map_foreach_key(&sign_map, name, {
|
||||||
sign_undefine_by_name(name);
|
kv_push(names, name);
|
||||||
});
|
});
|
||||||
|
for (size_t i = 0; i < kv_size(names); i++) {
|
||||||
|
sign_undefine_by_name(kv_A(names, i));
|
||||||
|
}
|
||||||
|
kv_destroy(names);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum {
|
static enum {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local clear, feed, exec, api = helpers.clear, helpers.feed, helpers.exec, helpers.api
|
local api, clear, eq = helpers.api, helpers.clear, helpers.eq
|
||||||
|
local eval, exec, feed = helpers.eval, helpers.exec, helpers.feed
|
||||||
|
|
||||||
describe('Signs', function()
|
describe('Signs', function()
|
||||||
local screen
|
local screen
|
||||||
@@ -565,4 +566,13 @@ describe('Signs', function()
|
|||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('sign_undefine() frees all signs', function()
|
||||||
|
exec([[
|
||||||
|
sign define 1 text=1
|
||||||
|
sign define 2 text=2
|
||||||
|
call sign_undefine()
|
||||||
|
]])
|
||||||
|
eq({}, eval('sign_getdefined()'))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user