diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2023-03-25 02:24:24 +0100 |
---|---|---|
committer | Luuk van Baal <luukvbaal@gmail.com> | 2023-04-01 13:59:03 +0200 |
commit | 2a10f64e254375e77e1c5a6aeae3cd65cd122afb (patch) | |
tree | 5b3cc58c001d4a47de52796274dd7b2dcf51b0a8 /test/functional/api/extmark_spec.lua | |
parent | 2257ade3dc2daab5ee12d27807c0b3bcf103cd29 (diff) | |
download | rneovim-2a10f64e254375e77e1c5a6aeae3cd65cd122afb.tar.gz rneovim-2a10f64e254375e77e1c5a6aeae3cd65cd122afb.tar.bz2 rneovim-2a10f64e254375e77e1c5a6aeae3cd65cd122afb.zip |
feat(extmarks): extend nvim_buf_get_extmarks()
Problem: Can not get all extmarks in a buffer. Properties are missing
from the details array.
Solution: Allow getting all extmarks in a buffer by supplying a -1
"ns_id". Add missing properties to the details array.
Diffstat (limited to 'test/functional/api/extmark_spec.lua')
-rw-r--r-- | test/functional/api/extmark_spec.lua | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 3882fc90ca..4bd8f51904 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -1463,6 +1463,7 @@ describe('API/extmarks', function() end_line = 1 }) eq({ {1, 0, 0, { + ns_id = 1, end_col = 0, end_row = 1, right_gravity = true, @@ -1480,20 +1481,27 @@ describe('API/extmarks', function() it('can get details', function() set_extmark(ns, marks[1], 0, 0, { + conceal = "c", + cursorline_hl_group = "Statement", end_col = 0, - end_row = 1, - right_gravity = false, end_right_gravity = true, - priority = 0, + end_row = 1, hl_eol = true, - hl_mode = "blend", hl_group = "String", - virt_text = { { "text", "Statement" } }, - virt_text_pos = "right_align", - virt_text_hide = true, + hl_mode = "blend", + line_hl_group = "Statement", + number_hl_group = "Statement", + priority = 0, + right_gravity = false, + sign_hl_group = "Statement", + sign_text = ">>", + spell = true, virt_lines = { { { "lines", "Statement" } }}, virt_lines_above = true, virt_lines_leftcol = true, + virt_text = { { "text", "Statement" } }, + virt_text_hide = true, + virt_text_pos = "right_align", }) set_extmark(ns, marks[2], 0, 0, { priority = 0, @@ -1501,22 +1509,31 @@ describe('API/extmarks', function() virt_text_win_col = 1, }) eq({0, 0, { + conceal = "c", + cursorline_hl_group = "Statement", end_col = 0, - end_row = 1, - right_gravity = false, end_right_gravity = true, - priority = 0, + end_row = 1, hl_eol = true, - hl_mode = "blend", hl_group = "String", - virt_text = { { "text", "Statement" } }, - virt_text_pos = "right_align", - virt_text_hide = true, + hl_mode = "blend", + line_hl_group = "Statement", + ns_id = 1, + number_hl_group = "Statement", + priority = 0, + right_gravity = false, + sign_hl_group = "Statement", + sign_text = ">>", + spell = true, virt_lines = { { { "lines", "Statement" } }}, virt_lines_above = true, virt_lines_leftcol = true, + virt_text = { { "text", "Statement" } }, + virt_text_hide = true, + virt_text_pos = "right_align", } }, get_extmark_by_id(ns, marks[1], { details = true })) eq({0, 0, { + ns_id = 1, right_gravity = true, priority = 0, virt_text = { { "text", "Statement" } }, @@ -1525,6 +1542,29 @@ describe('API/extmarks', function() virt_text_win_col = 1, } }, get_extmark_by_id(ns, marks[2], { details = true })) end) + + it('can get marks from anonymous namespaces', function() + ns = request('nvim_create_namespace', "") + ns2 = request('nvim_create_namespace', "") + set_extmark(ns, 1, 0, 0, {}) + set_extmark(ns2, 2, 1, 0, {}) + eq({{ 1, 0, 0, { ns_id = ns, right_gravity = true }}, + { 2, 1, 0, { ns_id = ns2, right_gravity = true }}}, + get_extmarks(-1, 0, -1, { details = true })) + end) + + it('can filter by extmark properties', function() + set_extmark(ns, 1, 0, 0, {}) + set_extmark(ns, 2, 0, 0, { hl_group = 'Normal' }) + set_extmark(ns, 3, 0, 0, { sign_text = '>>' }) + set_extmark(ns, 4, 0, 0, { virt_text = {{'text', 'Normal'}}}) + set_extmark(ns, 5, 0, 0, { virt_lines = {{{ 'line', 'Normal' }}}}) + eq(5, #get_extmarks(-1, 0, -1, { details = true })) + eq({{ 2, 0, 0 }}, get_extmarks(-1, 0, -1, { type = 'highlight' })) + eq({{ 3, 0, 0 }}, get_extmarks(-1, 0, -1, { type = 'sign' })) + eq({{ 4, 0, 0 }}, get_extmarks(-1, 0, -1, { type = 'virt_text' })) + eq({{ 5, 0, 0 }}, get_extmarks(-1, 0, -1, { type = 'virt_lines' })) + end) end) describe('Extmarks buffer api with many marks', function() |