aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/extmark_spec.lua30
-rw-r--r--test/functional/ui/decorations_spec.lua43
2 files changed, 72 insertions, 1 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index 0a286965f2..2acfbfc949 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -1798,6 +1798,36 @@ describe('API/extmarks', function()
eq(1, #extmarks)
eq('https://example.com', extmarks[1][4].url)
end)
+
+ it('respects priority', function()
+ screen = Screen.new(15, 10)
+ screen:attach()
+
+ set_extmark(ns, marks[1], 0, 0, {
+ hl_group = 'Comment',
+ end_col = 2,
+ priority = 20,
+ })
+
+ -- Extmark defined after first extmark but has lower priority, first extmark "wins"
+ set_extmark(ns, marks[2], 0, 0, {
+ hl_group = 'String',
+ end_col = 2,
+ priority = 10,
+ })
+
+ screen:expect {
+ grid = [[
+ {1:12}34^5 |
+ {2:~ }|*8
+ |
+ ]],
+ attr_ids = {
+ [1] = { foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Blue1, bold = true },
+ },
+ }
+ end)
end)
describe('Extmarks buffer api with many marks', function()
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 7b3533454c..cb804f056d 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -687,7 +687,7 @@ describe('decorations providers', function()
]]}
end)
- it('can add new providers during redraw #26652', function()
+ it('can add new providers during redraw #26652', function()
setup_provider [[
local ns = api.nvim_create_namespace('test_no_add')
function on_do(...)
@@ -697,6 +697,47 @@ describe('decorations providers', function()
helpers.assert_alive()
end)
+
+ it('supports subpriorities (order of definitions in a query file #27131)', function()
+ insert(mulholland)
+ setup_provider [[
+ local test_ns = api.nvim_create_namespace('mulholland')
+ function on_do(event, ...)
+ if event == "line" then
+ local win, buf, line = ...
+ api.nvim_buf_set_extmark(buf, test_ns, line, 0, {
+ end_row = line + 1,
+ hl_eol = true,
+ hl_group = 'Comment',
+ ephemeral = true,
+ priority = 100,
+ _subpriority = 20,
+ })
+
+ -- This extmark is set last but has a lower subpriority, so the first extmark "wins"
+ api.nvim_buf_set_extmark(buf, test_ns, line, 0, {
+ end_row = line + 1,
+ hl_eol = true,
+ hl_group = 'String',
+ ephemeral = true,
+ priority = 100,
+ _subpriority = 10,
+ })
+ end
+ end
+ ]]
+
+ screen:expect{grid=[[
+ {4:// just to see if there was an accident }|
+ {4:// on Mulholland Drive }|
+ {4:try_start(); }|
+ {4:bufref_T save_buf; }|
+ {4:switch_buffer(&save_buf, buf); }|
+ {4:posp = getmark(mark, false); }|
+ {4:restore_buffer(&save_buf);^ }|
+ |
+ ]]}
+ end)
end)
local example_text = [[