diff options
Diffstat (limited to 'test/functional/ui/sign_spec.lua')
-rw-r--r-- | test/functional/ui/sign_spec.lua | 202 |
1 files changed, 138 insertions, 64 deletions
diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua index 7874c04c39..ff03d86979 100644 --- a/test/functional/ui/sign_spec.lua +++ b/test/functional/ui/sign_spec.lua @@ -14,6 +14,10 @@ describe('Signs', function() screen = Screen.new() screen:add_extra_attr_ids { [100] = { bold = true, foreground = Screen.colors.Magenta1 }, + [101] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Yellow1 }, + [102] = { foreground = Screen.colors.Brown, background = Screen.colors.Yellow }, + [103] = { background = Screen.colors.Yellow, reverse = true }, + [104] = { reverse = true, foreground = Screen.colors.Grey100, background = Screen.colors.Red }, } end) @@ -27,8 +31,8 @@ describe('Signs', function() sign place 2 line=2 name=piet2 buffer=1 ]]) screen:expect([[ - {10:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}a | - {10:𠜎̀́̂̃̄̅}b | + {101:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}a | + {101:𠜎̀́̂̃̄̅}b | {7: }^ | {1:~ }|*10 | @@ -45,9 +49,9 @@ describe('Signs', function() sign place 3 line=1 name=pietx buffer=1 ]]) screen:expect([[ - {10:>!}a | + {101:>!}a | {7: }b | - {10:>>}c | + {101:>>}c | {7: }^ | {1:~ }|*9 | @@ -80,13 +84,13 @@ describe('Signs', function() ]]) screen:expect([[ {7: }{21:^a }| - {10:>>}b | + {101:>>}b | {7: }c | {7: } | {1:~ }|*2 {3:[No Name] [+] }| {7: }{21:a }| - {10:>>}b | + {101:>>}b | {7: }c | {7: } | {1:~ }| @@ -110,10 +114,10 @@ describe('Signs', function() sign place 6 line=4 name=pietxx buffer=1 ]]) screen:expect([[ - {10:>>}{8: 1 }a | + {101:>>}{8: 1 }a | {7: }{8: 2 }{9:b }| {7: }{13: 3 }c | - {10:>>}{13: 4 }{9:^ }| + {101:>>}{13: 4 }{9:^ }| {1:~ }|*9 | ]]) @@ -132,33 +136,33 @@ describe('Signs', function() set cursorline ]]) screen:expect([[ - {10:>>}a | - {10:>>}b | + {101:>>}a | + {101:>>}b | {9:>>}{21:^c }| {1:~ }|*10 | ]]) feed('k') screen:expect([[ - {10:>>}a | + {101:>>}a | {9:>>}{21:^b }| - {10:>>}c | + {101:>>}c | {1:~ }|*10 | ]]) exec('set nocursorline') screen:expect([[ - {10:>>}a | - {10:>>}^b | - {10:>>}c | + {101:>>}a | + {101:>>}^b | + {101:>>}c | {1:~ }|*10 | ]]) exec('set cursorline cursorlineopt=line') screen:expect([[ - {10:>>}a | - {10:>>}{21:^b }| - {10:>>}c | + {101:>>}a | + {101:>>}{21:^b }| + {101:>>}c | {1:~ }|*10 | ]]) @@ -166,13 +170,14 @@ describe('Signs', function() exec('hi! link SignColumn IncSearch') feed('Go<esc>2G') screen:expect([[ - {10:>>}a | - {9:>>}^b | - {10:>>}c | + {103:>>}a | + {104:>>}^b | + {103:>>}c | {2: } | {1:~ }|*9 | ]]) + -- Check that 'statuscolumn' cursorline/signcolumn highlights are the same (#21726) exec('set statuscolumn=%s') screen:expect_unchanged() @@ -196,7 +201,7 @@ describe('Signs', function() screen:expect([[ {7: }{8: 1 }a | {7: }{8: 2 }b | - WW{10:>>}{8: 3 }c | + {7:WW}{101:>>}{8: 3 }c | {7: }{8: 4 }^ | {1:~ }|*9 | @@ -209,9 +214,9 @@ describe('Signs', function() sign place 3 line=2 name=pietError buffer=1 ]]) screen:expect([[ - {9:XX}{10:>>}{8: 1 }a | - {10:>>}{9:XX}{8: 2 }b | - WW{10:>>}{8: 3 }c | + {9:XX}{101:>>}{8: 1 }a | + {101:>>}{9:XX}{8: 2 }b | + {7:WW}{101:>>}{8: 3 }c | {7: }{8: 4 }^ | {1:~ }|*9 | @@ -220,8 +225,8 @@ describe('Signs', function() exec('set signcolumn=yes:1') screen:expect([[ {9:XX}{8: 1 }a | - {10:>>}{8: 2 }b | - WW{8: 3 }c | + {101:>>}{8: 2 }b | + {7:WW}{8: 3 }c | {7: }{8: 4 }^ | {1:~ }|*9 | @@ -229,9 +234,9 @@ describe('Signs', function() -- "auto:3" accommodates all the signs we defined so far. exec('set signcolumn=auto:3') local s3 = [[ - {9:XX}{10:>>}{7: }{8: 1 }a | - {10:>>}{9:XX}{7: }{8: 2 }b | - WW{10:>>}{9:XX}{8: 3 }c | + {9:XX}{101:>>}{7: }{8: 1 }a | + {101:>>}{9:XX}{7: }{8: 2 }b | + {7:WW}{101:>>}{9:XX}{8: 3 }c | {7: }{8: 4 }^ | {1:~ }|*9 | @@ -240,9 +245,9 @@ describe('Signs', function() -- Check "yes:9". exec('set signcolumn=yes:9') screen:expect([[ - {9:XX}{10:>>}{7: }{8: 1 }a | - {10:>>}{9:XX}{7: }{8: 2 }b | - WW{10:>>}{9:XX}{7: }{8: 3 }c | + {9:XX}{101:>>}{7: }{8: 1 }a | + {101:>>}{9:XX}{7: }{8: 2 }b | + {7:WW}{101:>>}{9:XX}{7: }{8: 3 }c | {7: }{8: 4 }^ | {1:~ }|*9 | @@ -255,8 +260,8 @@ describe('Signs', function() exec('3move1') exec('2d') screen:expect([[ - {9:XX}{10:>>}{8: 1 }a | - {10:>>}{9:XX}{8: 2 }^b | + {9:XX}{101:>>}{8: 1 }a | + {101:>>}{9:XX}{8: 2 }^b | {7: }{8: 3 } | {1:~ }|*10 | @@ -264,8 +269,8 @@ describe('Signs', function() -- character deletion does not delete signs. feed('x') screen:expect([[ - {9:XX}{10:>>}{8: 1 }a | - {10:>>}{9:XX}{8: 2 }^ | + {9:XX}{101:>>}{8: 1 }a | + {101:>>}{9:XX}{8: 2 }^ | {7: }{8: 3 } | {1:~ }|*10 | @@ -301,7 +306,7 @@ describe('Signs', function() exec('sign define pietSearch text=>> texthl=Search') exec('sign place 1 line=1 name=pietSearch buffer=1') screen:expect([[ - {10:>>}{7: }{8: 1 }a | + {101:>>}{7: }{8: 1 }a | {7: }{8: 2 }b | {7: }{8: 3 }c | {7: }{8: 4 }^ | @@ -316,7 +321,7 @@ describe('Signs', function() sign place 4 line=1 name=pietSearch buffer=1 ]]) screen:expect([[ - {10:>>>>>>>>}{8: 1 }a | + {101:>>>>>>>>}{8: 1 }a | {7: }{8: 2 }b | {7: }{8: 3 }c | {7: }{8: 4 }^ | @@ -328,7 +333,7 @@ describe('Signs', function() screen:expect_unchanged() exec('sign unplace 4') screen:expect([[ - {10:>>>>>>}{8: 1 }a | + {101:>>>>>>}{8: 1 }a | {7: }{8: 2 }b | {7: }{8: 3 }c | {7: }{8: 4 }^ | @@ -345,7 +350,7 @@ describe('Signs', function() sign place 8 line=1 name=pietSearch buffer=1 ]]) screen:expect([[ - {10:>>>>>>>>>>}{8: 1 }a | + {101:>>>>>>>>>>}{8: 1 }a | {7: }{8: 2 }b | {7: }{8: 3 }c | {7: }{8: 4 }^ | @@ -375,7 +380,7 @@ describe('Signs', function() -- single column with 1 sign with text and one sign without exec('sign place 1 line=1 name=pietSearch buffer=1') screen:expect([[ - {10:>>}{8: 1 }a | + {101:>>}{8: 1 }a | {7: }{8: 2 }b | {7: }{8: 3 }c | {7: }{8: 4 }^ | @@ -396,7 +401,7 @@ describe('Signs', function() -- line number should be drawn if sign has no text -- no signcolumn, line number for "a" is Search, for "b" is Error, for "c" is LineNr screen:expect([[ - {10: >> }a | + {101: >> }a | {9: 2 }b | {8: 3 }c | {8: 4 }^ | @@ -406,7 +411,7 @@ describe('Signs', function() -- number column on wrapped part of a line should be empty feed('gg100aa<Esc>') screen:expect([[ - {10: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {101: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {9: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {9: }aa^a | {9: 2 }b | @@ -423,7 +428,7 @@ describe('Signs', function() -- number column on virtual lines should be empty screen:expect([[ {8: }VIRT LINES | - {10: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {101: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {9: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {9: }aa^a | {9: 2 }b | @@ -439,7 +444,7 @@ describe('Signs', function() exec('sign place 100000 line=1 name=piet buffer=1') feed(':sign place<cr>') screen:expect([[ - {10:>>} | + {101:>>} | {1:~ }|*6 {3: }| :sign place | @@ -452,7 +457,7 @@ describe('Signs', function() feed('<cr>') screen:expect([[ - {10:>>}^ | + {101:>>}^ | {1:~ }|*12 | ]]) @@ -470,7 +475,7 @@ describe('Signs', function() {7: }a | {7: }^c | {7: }d | - >>e | + {7:>>}e | {1:~ }|*9 | ]]) @@ -498,7 +503,7 @@ describe('Signs', function() {7: }b | {7: }c | {7: }d | - >>e | + {7:>>}e | {1:~ }|*7 | ]]) @@ -550,7 +555,7 @@ describe('Signs', function() exec('silent undo') screen:expect([[ {7: }1 | - S1^2 | + {7:S1}^2 | {7: }3 | {7: }4 | {1:~ }|*9 @@ -575,23 +580,19 @@ describe('Signs', function() sign place 2 line=9 name=S2 ]]) -- Now placed at end of buffer - local s1 = { - grid = [[ - S2^ | - {1:~ }|*12 - | - ]], - } + local s1 = [[ + {7:S2}^ | + {1:~ }|*12 + | + ]] screen:expect(s1) -- Signcolumn tracking used to not count signs placed beyond end of buffer here exec('set signcolumn=auto:9') - screen:expect({ - grid = [[ - S2S1^ | - {1:~ }|*12 - | - ]], - }) + screen:expect([[ + {7:S2S1}^ | + {1:~ }|*12 + | + ]]) -- Unplacing the sign does not crash by decrementing tracked signs below zero exec('sign unplace 1') screen:expect(s1) @@ -607,4 +608,77 @@ describe('Signs', function() eq(6, infos[1].textoff) eq(6, infos[2].textoff) end) + + it('auto width updated in all windows after sign placed in on_win #31438', function() + exec_lua([[ + vim.cmd.call('setline(1, range(1, 500))') + vim.cmd('wincmd s | wincmd v | wincmd j | wincmd v') + + _G.log, _G.needs_clear = {}, false + local ns_id, mark_id = vim.api.nvim_create_namespace('test'), nil + + -- Add decoration which possibly clears all extmarks and adds one on line 499 + local on_win = function(_, winid, bufnr, toprow, botrow) + if _G.needs_clear then + vim.api.nvim_buf_clear_namespace(bufnr, ns_id, 0, -1) + _G.needs_clear = false + end + + if toprow < 499 and 499 <= botrow then + mark_id = vim.api.nvim_buf_set_extmark(bufnr, ns_id, 499, 0, { id = mark_id, sign_text = '!', invalidate = true }) + end + end + vim.api.nvim_set_decoration_provider(ns_id, { on_win = on_win }) + ]]) + screen:expect([[ + 1 │1 | + 2 │2 | + 3 │3 | + 4 │4 | + 5 │5 | + 6 │6 | + {2:[No Name] [+] [No Name] [+] }| + ^1 │1 | + 2 │2 | + 3 │3 | + 4 │4 | + 5 │5 | + {3:[No Name] [+] }{2:[No Name] [+] }| + | + ]]) + feed('G') + screen:expect([[ + {7: }1 │{7: }1 | + {7: }2 │{7: }2 | + {7: }3 │{7: }3 | + {7: }4 │{7: }4 | + {7: }5 │{7: }5 | + {7: }6 │{7: }6 | + {2:[No Name] [+] [No Name] [+] }| + {7: }496 │{7: }1 | + {7: }497 │{7: }2 | + {7: }498 │{7: }3 | + {7: }499 │{7: }4 | + {7:! }^500 │{7: }5 | + {3:[No Name] [+] }{2:[No Name] [+] }| + | + ]]) + feed(':lua log, needs_clear = {}, true<CR>') + screen:expect([[ + {7: }1 │{7: }1 | + {7: }2 │{7: }2 | + {7: }3 │{7: }3 | + {7: }4 │{7: }4 | + {7: }5 │{7: }5 | + {7: }6 │{7: }6 | + {2:[No Name] [+] [No Name] [+] }| + {7: }496 │{7: }1 | + {7: }497 │{7: }2 | + {7: }498 │{7: }3 | + {7: }499 │{7: }4 | + {7:! }^500 │{7: }5 | + {3:[No Name] [+] }{2:[No Name] [+] }| + :lua log, needs_clear = {}, true | + ]]) + end) end) |