From 0c59771e314d6faaad69676985cd2a11c157ee37 Mon Sep 17 00:00:00 2001 From: bfredl Date: Fri, 22 Mar 2024 11:02:52 +0100 Subject: refactor(tests): all screen tests should use highlights This is the first installment of a multi-PR series significantly refactoring how highlights are being specified. The end goal is to have a base set of 20 ish most common highlights, and then specific files only need to add more groups to that as needed. As a complicating factor, we also want to migrate to the new default color scheme eventually. But by sharing a base set, that future PR will hopefully be a lot smaller since a lot of tests will be migrated just simply by updating the base set in place. As a first step, fix the anti-pattern than Screen defaults to ignoring highlights. Highlights are integral part of the screen state, not something "extra" which we only test "sometimes". For now, we still allow opt-out via the intentionally ugly screen._default_attr_ids = nil The end goal is to get rid of all of these eventually (which will be easier as part of the color scheme migration) --- test/functional/api/extmark_spec.lua | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'test/functional/api/extmark_spec.lua') diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 2acfbfc949..4cf96a4af6 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -460,7 +460,7 @@ describe('API/extmarks', function() -- This shouldn't seg fault screen:expect([[ 12345^ 1 | - ~ |*8 + {1:~ }|*8 | ]]) end) @@ -513,7 +513,7 @@ describe('API/extmarks', function() insert('abc') screen:expect([[ ab^c12345 | - ~ |*8 + {1:~ }|*8 | ]]) local rv = get_extmark_by_id(ns, marks[1]) @@ -1734,16 +1734,17 @@ describe('API/extmarks', function() command('d2') screen:expect([[ S2^aaa bbb ccc | - aaa bbb ccc |*3 - |*2 + {7: }aaa bbb ccc |*3 + {7: } | + | ]]) -- mark is restored with undo_restore == true command('silent undo') screen:expect([[ - S1 ^aaa bbb ccc | + S1{7: }^aaa bbb ccc | S1S2aaa bbb ccc | - S2 aaa bbb ccc | - aaa bbb ccc |*2 + S2{7: }aaa bbb ccc | + {7: }aaa bbb ccc |*2 | ]]) -- decor is not removed twice @@ -1964,7 +1965,7 @@ describe('API/win_extmark', function() grid = [[ non ui-watched line | ui-watched lin^e | - ~ | + {1:~ }| | ]], extmarks = { @@ -2052,7 +2053,7 @@ describe('API/win_extmark', function() grid = [[ ui-watched linupdat^e| e | - ~ | + {1:~ }| | ]], extmarks = { @@ -2079,9 +2080,9 @@ describe('API/win_extmark', function() grid = [[ ## grid 1 [4:--------------------]|*3 - [No Name] [+] | + {3:[No Name] [+] }| [2:--------------------]|*2 - [No Name] [+] | + {2:[No Name] [+] }| [3:--------------------]| ## grid 2 non ui-watched line | @@ -2091,7 +2092,7 @@ describe('API/win_extmark', function() ## grid 4 non ui-watched line | ui-watched lin^e | - ~ | + {1:~ }| ]], extmarks = { [2] = { @@ -2112,13 +2113,13 @@ describe('API/win_extmark', function() grid = [[ ## grid 1 [4:--------------------]|*3 - [No Name] [+] | + {3:[No Name] [+] }| [2:--------------------]|*2 - [No Name] [+] | + {2:[No Name] [+] }| [3:--------------------]| ## grid 2 non ui-watched line | - ui-watched linupd@@@| + ui-watched linupd{1:@@@}| ## grid 3 | ## grid 4 -- cgit From 7035125b2b26aa68fcfb7cda39377ac79926a0f9 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 8 Apr 2024 11:03:20 +0200 Subject: test: improve test conventions Work on https://github.com/neovim/neovim/issues/27004. --- test/functional/api/extmark_spec.lua | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'test/functional/api/extmark_spec.lua') diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 4cf96a4af6..1a96510d3d 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -1,20 +1,20 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) local Screen = require('test.functional.ui.screen') -local request = helpers.request -local eq = helpers.eq -local ok = helpers.ok -local pcall_err = helpers.pcall_err -local insert = helpers.insert -local feed = helpers.feed -local clear = helpers.clear -local command = helpers.command -local exec = helpers.exec -local api = helpers.api -local assert_alive = helpers.assert_alive +local request = t.request +local eq = t.eq +local ok = t.ok +local pcall_err = t.pcall_err +local insert = t.insert +local feed = t.feed +local clear = t.clear +local command = t.command +local exec = t.exec +local api = t.api +local assert_alive = t.assert_alive local function expect(contents) - return eq(contents, helpers.curbuf_contents()) + return eq(contents, t.curbuf_contents()) end local function set_extmark(ns_id, id, line, col, opts) -- cgit From 81fc27124b9e1b375e0ce9605ae69c3c2a2d9222 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 9 Apr 2024 12:26:16 +0100 Subject: refactor(test): inject after_each differently --- test/functional/api/extmark_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/api/extmark_spec.lua') diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 1a96510d3d..82e7ad3988 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local Screen = require('test.functional.ui.screen') local request = t.request -- cgit From 052498ed42780a76daea589d063cd8947a894673 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 20 Apr 2024 17:44:13 +0200 Subject: test: improve test conventions Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004. --- test/functional/api/extmark_spec.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'test/functional/api/extmark_spec.lua') diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 82e7ad3988..70bdb050e5 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -1,20 +1,21 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local request = t.request +local request = n.request local eq = t.eq local ok = t.ok local pcall_err = t.pcall_err -local insert = t.insert -local feed = t.feed -local clear = t.clear -local command = t.command -local exec = t.exec -local api = t.api -local assert_alive = t.assert_alive +local insert = n.insert +local feed = n.feed +local clear = n.clear +local command = n.command +local exec = n.exec +local api = n.api +local assert_alive = n.assert_alive local function expect(contents) - return eq(contents, t.curbuf_contents()) + return eq(contents, n.curbuf_contents()) end local function set_extmark(ns_id, id, line, col, opts) -- cgit From d44ed3a885e163df33cce8180ca9f72fb5c0661a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 3 May 2024 18:02:25 +0800 Subject: perf(extmarks): better track whether namespace has extmarks (#28615) This avoids redraw when adding/removing an empty namespace for a window. This also avoids marktree traversal when clearing a namespace that has already been cleared, which is added as a benchmark. --- test/functional/api/extmark_spec.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/functional/api/extmark_spec.lua') diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 70bdb050e5..965a60417a 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -1896,6 +1896,24 @@ describe('Extmarks buffer api with many marks', function() end eq(ns_marks[ns1], get_marks(ns1)) eq(ns_marks[ns2], get_marks(ns2)) + + api.nvim_buf_clear_namespace(0, ns1, 0, 10) + for id, mark in pairs(ns_marks[ns1]) do + if mark[1] < 10 then + ns_marks[ns1][id] = nil + end + end + eq(ns_marks[ns1], get_marks(ns1)) + eq(ns_marks[ns2], get_marks(ns2)) + + api.nvim_buf_clear_namespace(0, ns1, 20, -1) + for id, mark in pairs(ns_marks[ns1]) do + if mark[1] >= 20 then + ns_marks[ns1][id] = nil + end + end + eq(ns_marks[ns1], get_marks(ns1)) + eq(ns_marks[ns2], get_marks(ns2)) end) it('can delete line', function() -- cgit From 4e5c633ed4871a948aff7338b793ac5f93484153 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 12 May 2024 05:39:33 +0800 Subject: fix(api): make getting explicit empty hl in virtual text work (#28697) --- test/functional/api/extmark_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/api/extmark_spec.lua') diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 965a60417a..5ab3e09bf8 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -1569,7 +1569,7 @@ describe('API/extmarks', function() sign_text = '>>', spell = true, virt_lines = { - { { 'lines', 'Macro' }, { '???' } }, + { { 'lines', 'Macro' }, { '???' }, { ';;;', '' } }, { { 'stack', { 'Type', 'Search' } }, { '!!!' } }, }, virt_lines_above = true, @@ -1604,7 +1604,7 @@ describe('API/extmarks', function() sign_text = '>>', spell = true, virt_lines = { - { { 'lines', 'Macro' }, { '???' } }, + { { 'lines', 'Macro' }, { '???' }, { ';;;', '' } }, { { 'stack', { 'Type', 'Search' } }, { '!!!' } }, }, virt_lines_above = true, -- cgit From ad191be65e2b1641c181506166b1037b548d14a8 Mon Sep 17 00:00:00 2001 From: Tobias Schmitz Date: Tue, 21 May 2024 18:21:42 +0200 Subject: feat(signs)!: place higher-priority signs from the left #27781 Problem: Higher-priority signs may be hidden by lower-priority signs. Solution: Place higher-priority signs from the left. Example: nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='H', priority=1}) nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='W', priority=2}) nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='E', priority=3}) Before: | | H | W E | ^ | | Not visible After: | | | E W | H | | ^ Not visible Fixes #16632 --- test/functional/api/extmark_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/api/extmark_spec.lua') diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 5ab3e09bf8..7b2fe209ba 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -1743,7 +1743,7 @@ describe('API/extmarks', function() command('silent undo') screen:expect([[ S1{7: }^aaa bbb ccc | - S1S2aaa bbb ccc | + S2S1aaa bbb ccc | S2{7: }aaa bbb ccc | {7: }aaa bbb ccc |*2 | -- cgit