From 51cf84daf9612574978731e66db45a52136b8899 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 20 Feb 2025 21:47:12 +0800 Subject: feat(marks): virtual lines support horizontal scrolling (#32497) Add a new field `virt_lines_overflow` that enables horizontal scrolling for virtual lines when set to "scroll". --- test/functional/api/extmark_spec.lua | 56 ++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 12 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 8a4aea1efe..fd392d479d 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -123,6 +123,10 @@ describe('API/extmarks', function() pcall_err(set_extmark, ns, marks[2], 0, 0, { hl_mode = 0 }) ) eq("Invalid 'hl_mode': 'foo'", pcall_err(set_extmark, ns, marks[2], 0, 0, { hl_mode = 'foo' })) + eq( + "Invalid 'virt_lines_overflow': 'foo'", + pcall_err(set_extmark, ns, marks[2], 0, 0, { virt_lines_overflow = 'foo' }) + ) eq( "Invalid 'id': expected Integer, got Array", pcall_err(set_extmark, ns, {}, 0, 0, { end_col = 1, end_row = 1 }) @@ -1576,11 +1580,6 @@ describe('API/extmarks', function() virt_text_hide = true, virt_text_pos = 'right_align', }) - set_extmark(ns, marks[2], 0, 0, { - priority = 0, - virt_text = { { '', 'Macro' }, { '', { 'Type', 'Search' } }, { '' } }, - virt_text_win_col = 1, - }) eq({ 0, 0, @@ -1607,12 +1606,20 @@ describe('API/extmarks', function() }, virt_lines_above = true, virt_lines_leftcol = true, + virt_lines_overflow = 'trunc', virt_text = { { 'text', 'Macro' }, { '???' }, { 'stack', { 'Type', 'Search' } } }, virt_text_repeat_linebreak = false, virt_text_hide = true, virt_text_pos = 'right_align', }, }, get_extmark_by_id(ns, marks[1], { details = true })) + + set_extmark(ns, marks[2], 0, 0, { + priority = 0, + virt_text = { { '', 'Macro' }, { '', { 'Type', 'Search' } }, { '' } }, + virt_text_repeat_linebreak = true, + virt_text_win_col = 1, + }) eq({ 0, 0, @@ -1621,13 +1628,35 @@ describe('API/extmarks', function() right_gravity = true, priority = 0, virt_text = { { '', 'Macro' }, { '', { 'Type', 'Search' } }, { '' } }, - virt_text_repeat_linebreak = false, + virt_text_repeat_linebreak = true, virt_text_hide = false, virt_text_pos = 'win_col', virt_text_win_col = 1, }, }, get_extmark_by_id(ns, marks[2], { details = true })) - set_extmark(ns, marks[3], 0, 0, { cursorline_hl_group = 'Statement' }) + + set_extmark(ns, marks[3], 0, 0, { + priority = 0, + ui_watched = true, + virt_lines = { { { '', 'Macro' }, { '' }, { '', '' } } }, + virt_lines_overflow = 'scroll', + }) + eq({ + 0, + 0, + { + ns_id = 1, + right_gravity = true, + ui_watched = true, + priority = 0, + virt_lines = { { { '', 'Macro' }, { '' }, { '', '' } } }, + virt_lines_above = false, + virt_lines_leftcol = false, + virt_lines_overflow = 'scroll', + }, + }, get_extmark_by_id(ns, marks[3], { details = true })) + + set_extmark(ns, marks[4], 0, 0, { cursorline_hl_group = 'Statement' }) eq({ 0, 0, @@ -1637,8 +1666,9 @@ describe('API/extmarks', function() priority = 4096, right_gravity = true, }, - }, get_extmark_by_id(ns, marks[3], { details = true })) - set_extmark(ns, marks[4], 0, 0, { + }, get_extmark_by_id(ns, marks[4], { details = true })) + + set_extmark(ns, marks[5], 0, 0, { end_col = 1, conceal = 'a', spell = true, @@ -1655,8 +1685,9 @@ describe('API/extmarks', function() right_gravity = true, spell = true, }, - }, get_extmark_by_id(ns, marks[4], { details = true })) - set_extmark(ns, marks[5], 0, 0, { + }, get_extmark_by_id(ns, marks[5], { details = true })) + + set_extmark(ns, marks[6], 0, 0, { end_col = 1, spell = false, }) @@ -1671,7 +1702,8 @@ describe('API/extmarks', function() right_gravity = true, spell = false, }, - }, get_extmark_by_id(ns, marks[5], { details = true })) + }, get_extmark_by_id(ns, marks[6], { details = true })) + api.nvim_buf_clear_namespace(0, ns, 0, -1) -- legacy sign mark includes sign name command('sign define sign1 text=s1 texthl=Title linehl=LineNR numhl=Normal culhl=CursorLine') -- cgit