diff options
Diffstat (limited to 'test/functional/ui')
-rw-r--r-- | test/functional/ui/bufhl_spec.lua | 22 | ||||
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 26 |
2 files changed, 31 insertions, 17 deletions
diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua index b7cf8504ff..58fd50e724 100644 --- a/test/functional/ui/bufhl_spec.lua +++ b/test/functional/ui/bufhl_spec.lua @@ -577,7 +577,7 @@ describe('Buffer highlighting', function() end) describe('virtual text decorations', function() - local id1, id2 + local id1, id2 ---@type integer, integer before_each(function() insert([[ 1 + 2 @@ -709,7 +709,7 @@ describe('Buffer highlighting', function() 0, 0, { - ns_id = 1, + ns_id = id1, priority = 0, virt_text = s1, -- other details @@ -729,7 +729,7 @@ describe('Buffer highlighting', function() lastline, 0, { - ns_id = 1, + ns_id = id1, priority = 0, virt_text = s2, -- other details @@ -898,11 +898,15 @@ describe('Buffer highlighting', function() end) it('and virtual text use the same namespace counter', function() - eq(1, add_highlight(0, 0, 'String', 0, 0, -1)) - eq(2, set_virtual_text(0, 0, 0, { { '= text', 'Comment' } }, {})) - eq(3, api.nvim_create_namespace('my-ns')) - eq(4, add_highlight(0, 0, 'String', 0, 0, -1)) - eq(5, set_virtual_text(0, 0, 0, { { '= text', 'Comment' } }, {})) - eq(6, api.nvim_create_namespace('other-ns')) + local base = vim.iter(api.nvim_get_namespaces()):fold(0, function(acc, _, v) + return math.max(acc, v) + end) + + eq(base + 1, add_highlight(0, 0, 'String', 0, 0, -1)) + eq(base + 2, set_virtual_text(0, 0, 0, { { '= text', 'Comment' } }, {})) + eq(base + 3, api.nvim_create_namespace('my-ns')) + eq(base + 4, add_highlight(0, 0, 'String', 0, 0, -1)) + eq(base + 5, set_virtual_text(0, 0, 0, { { '= text', 'Comment' } }, {})) + eq(base + 6, api.nvim_create_namespace('other-ns')) end) end) diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 872e8d1457..d680e8b96e 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -16,7 +16,7 @@ local assert_alive = n.assert_alive local pcall_err = t.pcall_err describe('decorations providers', function() - local screen + local screen ---@type test.functional.ui.screen before_each(function() clear() screen = Screen.new(40, 8) @@ -52,6 +52,7 @@ describe('decorations providers', function() posp = getmark(mark, false); restore_buffer(&save_buf); ]] + --- @return integer local function setup_provider(code) return exec_lua ([[ local api = vim.api @@ -848,7 +849,8 @@ for _,item in ipairs(items) do end]] describe('extmark decorations', function() - local screen, ns + local screen ---@type test.functional.ui.screen + local ns ---@type integer before_each( function() clear() screen = Screen.new(50, 15) @@ -2232,7 +2234,7 @@ describe('extmark decorations', function() eq({ { 1, 0, 8, { end_col = 13, end_right_gravity = false, end_row = 0, hl_eol = false, hl_group = "NonText", undo_restore = false, - ns_id = 1, priority = 4096, right_gravity = true } } }, + ns_id = ns, priority = 4096, right_gravity = true } } }, api.nvim_buf_get_extmarks(0, ns, {0,0}, {0, -1}, {details=true})) end) @@ -2933,7 +2935,8 @@ describe('extmark decorations', function() end) describe('decorations: inline virtual text', function() - local screen, ns + local screen ---@type test.functional.ui.screen + local ns ---@type integer before_each( function() clear() screen = Screen.new(50, 3) @@ -4675,7 +4678,9 @@ describe('decorations: inline virtual text', function() end) describe('decorations: virtual lines', function() - local screen, ns + local screen ---@type test.functional.ui.screen + local ns ---@type integer + before_each(function() clear() screen = Screen.new(50, 12) @@ -5732,7 +5737,9 @@ if (h->n_buckets < new_n_buckets) { // expand end) describe('decorations: signs', function() - local screen, ns + local screen ---@type test.functional.ui.screen + local ns ---@type integer + before_each(function() clear() screen = Screen.new(50, 10) @@ -6342,7 +6349,7 @@ l5 end) describe('decorations: virt_text', function() - local screen + local screen ---@type test.functional.ui.screen before_each(function() clear() @@ -6416,7 +6423,10 @@ describe('decorations: virt_text', function() end) describe('decorations: window scoped', function() - local screen, ns, win_other + local screen ---@type test.functional.ui.screen + local ns ---@type integer + local win_other ---@type integer + local url = 'https://example.com' before_each(function() clear() |