From 28ffd96c9b3912b65bbe0ad0fe8fb123407a6d1e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 28 Sep 2023 20:20:25 +0800 Subject: test: decoration provider with wrapped lines (#25404) --- test/functional/ui/decorations_spec.lua | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index f535bdd1a6..2c4bcadc4b 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -521,6 +521,72 @@ describe('decorations providers', function() ]]} end) + it('virtual text works with wrapped lines', function() + insert(mulholland) + feed('ggJj3JjJ') + setup_provider [[ + local hl = api.nvim_get_hl_id_by_name "ErrorMsg" + local test_ns = api.nvim_create_namespace "mulholland" + function on_do(event, ...) + if event == "line" then + local win, buf, line = ... + api.nvim_buf_set_extmark(buf, test_ns, line, 0, { + virt_text = {{string.rep('/', line+1), 'ErrorMsg'}}; + virt_text_pos='eol'; + ephemeral = true; + }) + api.nvim_buf_set_extmark(buf, test_ns, line, 6, { + virt_text = {{string.rep('*', line+1), 'ErrorMsg'}}; + virt_text_pos='overlay'; + ephemeral = true; + }) + api.nvim_buf_set_extmark(buf, test_ns, line, 39, { + virt_text = {{string.rep('!', line+1), 'ErrorMsg'}}; + virt_text_win_col=20; + ephemeral = true; + }) + api.nvim_buf_set_extmark(buf, test_ns, line, 40, { + virt_text = {{string.rep('?', line+1), 'ErrorMsg'}}; + virt_text_win_col=10; + ephemeral = true; + }) + api.nvim_buf_set_extmark(buf, test_ns, line, 40, { + virt_text = {{string.rep(';', line+1), 'ErrorMsg'}}; + virt_text_pos='overlay'; + ephemeral = true; + }) + api.nvim_buf_set_extmark(buf, test_ns, line, 40, { + virt_text = {{'+'}, {string.rep(' ', line+1), 'ErrorMsg'}}; + virt_text_pos='right_align'; + ephemeral = true; + }) + end + end + ]] + + screen:expect{grid=[[ + // jus{2:*} to see if th{2:!}re was an accident | + {2:;}n Mulholl{2:?}nd Drive {2:/} +{2: }| + try_st{2:**}t(); bufref_{2:!!}save_buf; switch_b| + {2:;;}fer(&sav{2:??}buf, buf); {2://} +{2: }| + posp ={2:***}tmark(mark,{2:!!!}lse);^ restore_buf| + {2:;;;}(&save_{2:???}); {2:///} +{2: }| + {1:~ }| + | + ]]} + command('setlocal breakindent breakindentopt=shift:2') + screen:expect{grid=[[ + // jus{2:*} to see if th{2:!}re was an accident | + {2:;}n Mulho{2:?}land Drive {2:/} +{2: }| + try_st{2:**}t(); bufref_{2:!!}save_buf; switch_b| + {2:;;}fer(&s{2:??}e_buf, buf); {2://} +{2: }| + posp ={2:***}tmark(mark,{2:!!!}lse);^ restore_buf| + {2:;;;}(&sav{2:???}uf); {2:///} +{2: }| + {1:~ }| + | + ]]} + end) + it('can highlight beyond EOL', function() insert(mulholland) setup_provider [[ -- cgit