aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2018-12-07 18:49:00 +0100
committerGitHub <noreply@github.com>2018-12-07 18:49:00 +0100
commitb93670174e049d734f5c28be38f1eb3ef6776da6 (patch)
treec00bb1f8d2e4732464d6f1619cd38b2600fbcb6b
parent769762834533292e1d6a34b3846213d3896dc386 (diff)
parentb4a04fd80c4a223a80257ca1670e1907a6a95fdd (diff)
downloadrneovim-b93670174e049d734f5c28be38f1eb3ef6776da6.tar.gz
rneovim-b93670174e049d734f5c28be38f1eb3ef6776da6.tar.bz2
rneovim-b93670174e049d734f5c28be38f1eb3ef6776da6.zip
Merge pull request #9324 from bfredl/virtfix
api: make nvim_set_virtual_text use correct namespace counter
-rw-r--r--src/nvim/buffer.c3
-rw-r--r--test/functional/ui/bufhl_spec.lua10
2 files changed, 11 insertions, 2 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 634e257d40..8b107041b1 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -5396,9 +5396,8 @@ int bufhl_add_virt_text(buf_T *buf,
linenr_T lnum,
VirtText virt_text)
{
- static int next_src_id = 1;
if (src_id == 0) {
- src_id = next_src_id++;
+ src_id = (int)nvim_create_namespace((String)STRING_INIT);
}
BufhlLine *lineinfo = bufhl_tree_ref(&buf->b_bufhl_info, lnum, true);
diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua
index f0c9ea42b9..bcccef84b6 100644
--- a/test/functional/ui/bufhl_spec.lua
+++ b/test/functional/ui/bufhl_spec.lua
@@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local command, neq = helpers.command, helpers.neq
+local meths = helpers.meths
local curbufmeths, eq = helpers.curbufmeths, helpers.eq
describe('Buffer highlighting', function()
@@ -517,4 +518,13 @@ describe('Buffer highlighting', function()
end)
end)
+ it('and virtual text use the same namespace counter', function()
+ local set_virtual_text = curbufmeths.set_virtual_text
+ eq(1, add_highlight(0, "String", 0 , 0, -1))
+ eq(2, set_virtual_text(0, 0, {{"= text", "Comment"}}, {}))
+ eq(3, meths.create_namespace("my-ns"))
+ eq(4, add_highlight(0, "String", 0 , 0, -1))
+ eq(5, set_virtual_text(0, 0, {{"= text", "Comment"}}, {}))
+ eq(6, meths.create_namespace("other-ns"))
+ end)
end)