diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-07-29 11:31:59 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2021-07-29 12:59:56 +0200 |
commit | cd353aa82484f2a849c2ec614b2753ad63fd1a9c (patch) | |
tree | 237318244035813c2bcdce05eb7538bb66e24318 | |
parent | ac5139eae412c5b80ffe5fb5f3d1c9461bf91940 (diff) | |
download | rneovim-cd353aa82484f2a849c2ec614b2753ad63fd1a9c.tar.gz rneovim-cd353aa82484f2a849c2ec614b2753ad63fd1a9c.tar.bz2 rneovim-cd353aa82484f2a849c2ec614b2753ad63fd1a9c.zip |
fix(decorations): crash when :bdelete (extmark_free_all) after clear_namespace
fixes #15212
-rw-r--r-- | src/nvim/extmark.c | 2 | ||||
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 46 |
2 files changed, 47 insertions, 1 deletions
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index 60b7b024f1..4b2dccd8a4 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -268,7 +268,7 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id, } ExtmarkNs *my_ns = all_ns ? buf_ns_ref(buf, item.ns_id, false) : ns; map_del(uint64_t, uint64_t)(my_ns->map, item.mark_id); - map_del(uint64_t, ExtmarkItem)(buf->b_extmark_index, mark.id); + map_del(uint64_t, ExtmarkItem)(buf->b_extmark_index, start_id); marktree_del_itr(buf->b_marktree, itr, false); } else { marktree_itr_next(buf->b_marktree, itr); diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 98aafd8757..0e4b3574e9 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -697,4 +697,50 @@ end]] | ]]} end) + it('does not crash when deleting a cleared buffer #15212', function() + exec_lua [[ + ns = vim.api.nvim_create_namespace("myplugin") + vim.api.nvim_buf_set_extmark(0, ns, 0, 0, {virt_text = {{"a"}}, end_col = 0}) + ]] + screen:expect{grid=[[ + ^ a | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + exec_lua [[ + vim.api.nvim_buf_clear_namespace(0, ns, 0, -1) + vim.cmd("bdelete") + ]] + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + helpers.assert_alive() + end) end) |