From c4afb9788c4f139eb2e3b7aa4d6a6a20b67ba156 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sat, 11 Nov 2023 00:52:50 +0100 Subject: refactor(sign): move legacy signs to extmarks Problem: The legacy signlist data structures and associated functions are redundant since the introduction of extmark signs. Solution: Store signs defined through the legacy commands in a hashmap, placed signs in the extmark tree. Replace signlist associated functions. Usage of the legacy sign commands should yield no change in behavior with the exception of: - "orphaned signs" are now always removed when the line it is placed on is deleted. This used to depend on the value of 'signcolumn'. - It is no longer possible to place multiple signs with the same identifier in a single group on multiple lines. This will now move the sign instead. Moreover, both signs placed through the legacy sign commands and through |nvim_buf_set_extmark()|: - Will show up in both |sign-place| and |nvim_buf_get_extmarks()|. - Are displayed by increasing sign identifier, left to right. Extmark signs used to be ordered decreasingly as opposed to legacy signs. --- test/functional/ui/sign_spec.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/functional/ui/sign_spec.lua') diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua index 7dcd4cff25..31b54ce0a2 100644 --- a/test/functional/ui/sign_spec.lua +++ b/test/functional/ui/sign_spec.lua @@ -274,9 +274,9 @@ describe('Signs', function() -- Line 3 checks that with a limit over the maximum number -- of signs, the ones with the highest Ids are being picked, -- and presented by their sorted Id order. - command('sign place 4 line=3 name=pietSearch buffer=1') - command('sign place 5 line=3 name=pietWarn buffer=1') - command('sign place 3 line=3 name=pietError buffer=1') + command('sign place 6 line=3 name=pietSearch buffer=1') + command('sign place 7 line=3 name=pietWarn buffer=1') + command('sign place 5 line=3 name=pietError buffer=1') screen:expect([[ {1:>>}{8:XX}{6: 1 }a | {8:XX}{1:>>}{6: 2 }b | -- cgit From c126a3756a09716ed64fd2acb9eee5d411c4aa7b Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Thu, 23 Nov 2023 12:58:17 +0100 Subject: fix(column): apply numhl signs when 'signcolumn' is "no" (#26167) --- test/functional/ui/sign_spec.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/functional/ui/sign_spec.lua') diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua index 31b54ce0a2..adab184a4c 100644 --- a/test/functional/ui/sign_spec.lua +++ b/test/functional/ui/sign_spec.lua @@ -685,4 +685,21 @@ describe('Signs', function() | ]]) end) + + it('numhl highlight is applied when signcolumn=no', function() + screen:try_resize(screen._width, 4) + command([[ + set nu scl=no + call setline(1, ['line1', 'line2', 'line3']) + call nvim_buf_set_extmark(0, nvim_create_namespace('test'), 0, 0, {'number_hl_group':'Error'}) + call sign_define('foo', { 'text':'F', 'numhl':'Error' }) + call sign_place(0, '', 'foo', bufnr(''), { 'lnum':2 }) + ]]) + screen:expect([[ + {8: 1 }^line1 | + {8: 2 }line2 | + {6: 3 }line3 | + | + ]]) + end) end) -- cgit From f4001d27efae44c6c07678ad2c72eed5f1a25ea8 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Tue, 28 Nov 2023 05:40:18 +0100 Subject: perf(column): only invalidate lines affected by added sign --- test/functional/ui/sign_spec.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/functional/ui/sign_spec.lua') diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua index adab184a4c..b12e79bd42 100644 --- a/test/functional/ui/sign_spec.lua +++ b/test/functional/ui/sign_spec.lua @@ -467,6 +467,27 @@ describe('Signs', function() {0:~ }| | ]]) + -- should not increase size because sign with existing id is moved + command('sign place 4 line=1 name=pietSearch buffer=1') + screen:expect_unchanged() + command('sign unplace 4') + screen:expect([[ + {1:>>>>>>}{6: 1 }a | + {2: }{6: 2 }b | + {2: }{6: 3 }c | + {2: }{6: 4 }^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + command('sign place 4 line=1 name=pietSearch buffer=1') -- should keep the column at maximum size when signs are -- exceeding the maximum command('sign place 5 line=1 name=pietSearch buffer=1') -- cgit