diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/api/extmark_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 22 | ||||
-rw-r--r-- | test/functional/ex_cmds/dict_notifications_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ex_cmds/swapfile_preserve_recover_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/helpers.lua | 18 | ||||
-rw-r--r-- | test/functional/lua/help_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/lua/json_spec.lua | 111 | ||||
-rw-r--r-- | test/functional/plugin/lsp/inlay_hint_spec.lua | 17 | ||||
-rw-r--r-- | test/functional/provider/clipboard_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/ui/cmdline_spec.lua | 39 | ||||
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 176 | ||||
-rw-r--r-- | test/functional/ui/fold_spec.lua | 80 | ||||
-rw-r--r-- | test/functional/vimscript/input_spec.lua | 2 | ||||
-rw-r--r-- | test/old/testdir/test_filetype.vim | 1 |
14 files changed, 386 insertions, 93 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 675c8332de..ec1c9245ba 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -105,6 +105,10 @@ describe('API/extmarks', function() it('validation', function() eq("Invalid 'end_col': expected Integer, got Array", pcall_err(set_extmark, ns, marks[2], 0, 0, { end_col = {}, end_row = 1 })) eq("Invalid 'end_row': expected Integer, got Array", pcall_err(set_extmark, ns, marks[2], 0, 0, { end_col = 1, end_row = {} })) + eq("Invalid 'virt_text_pos': expected String, got Integer", pcall_err(set_extmark, ns, marks[2], 0, 0, { virt_text_pos = 0 })) + eq("Invalid 'virt_text_pos': 'foo'", pcall_err(set_extmark, ns, marks[2], 0, 0, { virt_text_pos = 'foo' })) + eq("Invalid 'hl_mode': expected String, got Integer", 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 'id': expected positive Integer", pcall_err(set_extmark, ns, {}, 0, 0, { end_col = 1, end_row = 1 })) eq("Invalid mark position: expected 2 Integer items", pcall_err(get_extmarks, ns, {}, {-1, -1})) eq("Invalid mark position: expected mark id Integer or 2-item Array", pcall_err(get_extmarks, ns, true, {-1, -1})) diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 98e5482218..d56f780ca6 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -346,15 +346,15 @@ describe('API', function() os.remove(fname) end) - it('VimL validation error: fails with specific error', function() + it('Vimscript validation error: fails with specific error', function() local status, rv = pcall(nvim, "command", "bogus_command") eq(false, status) -- nvim_command() failed. - eq("E492:", string.match(rv, "E%d*:")) -- VimL error was returned. + eq("E492:", string.match(rv, "E%d*:")) -- Vimscript error was returned. eq('', nvim('eval', 'v:errmsg')) -- v:errmsg was not updated. eq('', eval('v:exception')) end) - it('VimL execution error: fails with specific error', function() + it('Vimscript execution error: fails with specific error', function() local status, rv = pcall(nvim, "command", "buffer 23487") eq(false, status) -- nvim_command() failed. eq("E86: Buffer 23487 does not exist", string.match(rv, "E%d*:.*")) @@ -422,7 +422,7 @@ describe('API', function() eq(':!echo foo\r\n\nfoo'..win_lf..'\n', nvim('command_output', [[!echo foo]])) end) - it('VimL validation error: fails with specific error', function() + it('Vimscript validation error: fails with specific error', function() local status, rv = pcall(nvim, "command_output", "bogus commannnd") eq(false, status) -- nvim_command_output() failed. eq("E492: Not an editor command: bogus commannnd", @@ -432,7 +432,7 @@ describe('API', function() eq({mode='n', blocking=false}, nvim("get_mode")) end) - it('VimL execution error: fails with specific error', function() + it('Vimscript execution error: fails with specific error', function() local status, rv = pcall(nvim, "command_output", "buffer 42") eq(false, status) -- nvim_command_output() failed. eq("E86: Buffer 42 does not exist", string.match(rv, "E%d*:.*")) @@ -463,7 +463,7 @@ describe('API', function() eq(2, request("vim_eval", "1+1")) end) - it("VimL error: returns error details, does NOT update v:errmsg", function() + it("Vimscript error: returns error details, does NOT update v:errmsg", function() eq('Vim:E121: Undefined variable: bogus', pcall_err(request, 'nvim_eval', 'bogus expression')) eq('', eval('v:errmsg')) -- v:errmsg was not updated. @@ -478,7 +478,7 @@ describe('API', function() eq('foo', nvim('call_function', 'simplify', {'this/./is//redundant/../../../foo'})) end) - it("VimL validation error: returns specific error, does NOT update v:errmsg", function() + it("Vimscript validation error: returns specific error, does NOT update v:errmsg", function() eq('Vim:E117: Unknown function: bogus function', pcall_err(request, 'nvim_call_function', 'bogus function', {'arg1'})) eq('Vim:E119: Not enough arguments for function: atan', @@ -487,7 +487,7 @@ describe('API', function() eq('', eval('v:errmsg')) -- v:errmsg was not updated. end) - it("VimL error: returns error details, does NOT update v:errmsg", function() + it("Vimscript error: returns error details, does NOT update v:errmsg", function() eq('Vim:E808: Number or Float required', pcall_err(request, 'nvim_call_function', 'atan', {'foo'})) eq('Vim:Invalid channel stream "xxx"', @@ -498,7 +498,7 @@ describe('API', function() eq('', eval('v:errmsg')) -- v:errmsg was not updated. end) - it("VimL exception: returns exception details, does NOT update v:errmsg", function() + it("Vimscript exception: returns exception details, does NOT update v:errmsg", function() source([[ function! Foo() abort throw 'wtf' @@ -523,7 +523,7 @@ describe('API', function() end) describe('nvim_call_dict_function', function() - it('invokes VimL dict function', function() + it('invokes Vimscript dict function', function() source([[ function! F(name) dict return self.greeting.', '.a:name.'!' @@ -653,7 +653,7 @@ describe('API', function() end) describe('nvim_input', function() - it("VimL error: does NOT fail, updates v:errmsg", function() + it("Vimscript error: does NOT fail, updates v:errmsg", function() local status, _ = pcall(nvim, "input", ":call bogus_fn()<CR>") local v_errnum = string.match(nvim("eval", "v:errmsg"), "E%d*:") eq(true, status) -- nvim_input() did not fail. diff --git a/test/functional/ex_cmds/dict_notifications_spec.lua b/test/functional/ex_cmds/dict_notifications_spec.lua index afa6b519d5..6a0b40bd88 100644 --- a/test/functional/ex_cmds/dict_notifications_spec.lua +++ b/test/functional/ex_cmds/dict_notifications_spec.lua @@ -9,7 +9,7 @@ local command = helpers.command local eval = helpers.eval -describe('VimL dictionary notifications', function() +describe('Vimscript dictionary notifications', function() local channel before_each(function() diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua index 639bc6c94e..206838408f 100644 --- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua +++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua @@ -191,7 +191,7 @@ describe('swapfile detection', function() feed('e') -- Chose "Edit" at the swap dialog. screen2:expect(expected_no_dialog) - -- With API (via eval/VimL) call and shortmess+=F + -- With API (via eval/Vimscript) call and shortmess+=F feed(':call nvim_command("edit %")<CR>') screen2:expect{any=[[Found a swap file by the name ".*]] ..[[Xtest_swapdialog_dir[/\].*]]..testfile..[[%.swp"]]} diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 6e668b22b0..67275b12a4 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -265,7 +265,7 @@ function module.nvim_prog_abs() end end --- Executes an ex-command. VimL errors manifest as client (lua) errors, but +-- Executes an ex-command. Vimscript errors manifest as client (lua) errors, but -- v:errmsg will not be updated. function module.command(cmd) module.request('nvim_command', cmd) @@ -289,26 +289,26 @@ function module.expect_exit(fn_or_timeout, ...) end end --- Evaluates a VimL expression. --- Fails on VimL error, but does not update v:errmsg. +-- Evaluates a Vimscript expression. +-- Fails on Vimscript error, but does not update v:errmsg. function module.eval(expr) return module.request('nvim_eval', expr) end --- Executes a VimL function via RPC. --- Fails on VimL error, but does not update v:errmsg. +-- Executes a Vimscript function via RPC. +-- Fails on Vimscript error, but does not update v:errmsg. function module.call(name, ...) return module.request('nvim_call_function', name, {...}) end --- Executes a VimL function via Lua. --- Fails on VimL error, but does not update v:errmsg. +-- Executes a Vimscript function via Lua. +-- Fails on Vimscript error, but does not update v:errmsg. function module.call_lua(name, ...) return module.exec_lua([[return vim.call(...)]], name, ...) end -- Sends user input to Nvim. --- Does not fail on VimL error, but v:errmsg will be updated. +-- Does not fail on Vimscript error, but v:errmsg will be updated. local function nvim_feed(input) while #input > 0 do local written = module.request('nvim_input', input) @@ -518,7 +518,7 @@ function module.insert(...) nvim_feed('<ESC>') end --- Executes an ex-command by user input. Because nvim_input() is used, VimL +-- Executes an ex-command by user input. Because nvim_input() is used, Vimscript -- errors will not manifest as client (lua) errors. Use command() for that. function module.feed_command(...) for _, v in ipairs({...}) do diff --git a/test/functional/lua/help_spec.lua b/test/functional/lua/help_spec.lua index d66d9f7fbe..cdc7761e48 100644 --- a/test/functional/lua/help_spec.lua +++ b/test/functional/lua/help_spec.lua @@ -21,6 +21,7 @@ describe(':help docs', function() ok(rv.helpfiles > 100, '>100 :help files', rv.helpfiles) eq({}, rv.invalid_links, 'invalid tags in :help docs') eq({}, rv.invalid_urls, 'invalid URLs in :help docs') + eq({}, rv.invalid_spelling, 'invalid spelling in :help docs') -- Check that parse errors did not increase. ok(rv.err_count == 0, 'no parse errors', rv.err_count) end) diff --git a/test/functional/lua/json_spec.lua b/test/functional/lua/json_spec.lua index fbb21bfd57..25fdb48eea 100644 --- a/test/functional/lua/json_spec.lua +++ b/test/functional/lua/json_spec.lua @@ -1,20 +1,57 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear -local NIL = helpers.NIL local exec_lua = helpers.exec_lua local eq = helpers.eq +local pcall_err = helpers.pcall_err -describe('vim.json.decode function', function() +describe('vim.json.decode()', function() before_each(function() clear() end) it('parses null, true, false', function() - eq(NIL, exec_lua([[return vim.json.decode('null')]])) + eq(vim.NIL, exec_lua([[return vim.json.decode('null')]])) eq(true, exec_lua([[return vim.json.decode('true')]])) eq(false, exec_lua([[return vim.json.decode('false')]])) end) + it('validation', function() + eq('Expected object key string but found invalid token at character 2', + pcall_err(exec_lua, [[return vim.json.decode('{a:"b"}')]])) + end) + + it('options', function() + local jsonstr = '{"arr":[1,2,null],"bar":[3,7],"foo":{"a":"b"},"baz":null}' + eq({ + arr = { 1, 2, vim.NIL }, + bar = { 3, 7 }, + baz = vim.NIL, + foo = { a = 'b' }, + }, + exec_lua([[return vim.json.decode(..., {})]], jsonstr)) + eq({ + arr = { 1, 2, vim.NIL }, + bar = { 3, 7 }, + -- baz = nil, + foo = { a = 'b' }, + }, + exec_lua([[return vim.json.decode(..., { luanil = { object = true } })]], jsonstr)) + eq({ + arr = { 1, 2 }, + bar = { 3, 7 }, + baz = vim.NIL, + foo = { a = 'b' }, + }, + exec_lua([[return vim.json.decode(..., { luanil = { array = true } })]], jsonstr)) + eq({ + arr = { 1, 2 }, + bar = { 3, 7 }, + -- baz = nil, + foo = { a = 'b' }, + }, + exec_lua([[return vim.json.decode(..., { luanil = { array = true, object = true } })]], jsonstr)) + end) + it('parses integer numbers', function() eq(100000, exec_lua([[return vim.json.decode('100000')]])) eq(-100000, exec_lua([[return vim.json.decode('-100000')]])) @@ -60,7 +97,7 @@ describe('vim.json.decode function', function() it('parses containers', function() eq({1}, exec_lua([[return vim.json.decode('[1]')]])) - eq({NIL, 1}, exec_lua([[return vim.json.decode('[null, 1]')]])) + eq({vim.NIL, 1}, exec_lua([[return vim.json.decode('[null, 1]')]])) eq({['1']=2}, exec_lua([[return vim.json.decode('{"1": 2}')]])) eq({['1']=2, ['3']={{['4']={['5']={{}, 1}}}}}, exec_lua([[return vim.json.decode('{"1": 2, "3": [{"4": {"5": [ [], 1]}}]}')]])) @@ -88,43 +125,43 @@ describe('vim.json.decode function', function() end) -describe('vim.json.encode function', function() +describe('vim.json.encode()', function() before_each(function() clear() end) - it('dumps strings', function() - eq('"Test"', exec_lua([[return vim.json.encode('Test')]])) - eq('""', exec_lua([[return vim.json.encode('')]])) - eq('"\\t"', exec_lua([[return vim.json.encode('\t')]])) - eq('"\\n"', exec_lua([[return vim.json.encode('\n')]])) - -- vim.fn.json_encode return \\u001B - eq('"\\u001b"', exec_lua([[return vim.json.encode('\27')]])) - eq('"þÿþ"', exec_lua([[return vim.json.encode('þÿþ')]])) - end) - - it('dumps numbers', function() - eq('0', exec_lua([[return vim.json.encode(0)]])) - eq('10', exec_lua([[return vim.json.encode(10)]])) - eq('-10', exec_lua([[return vim.json.encode(-10)]])) - end) - - it('dumps floats', function() - eq('10.5', exec_lua([[return vim.json.encode(10.5)]])) - eq('-10.5', exec_lua([[return vim.json.encode(-10.5)]])) - eq('-1e-05', exec_lua([[return vim.json.encode(-1e-5)]])) - end) - - it('dumps lists', function() - eq('[]', exec_lua([[return vim.json.encode({})]])) - eq('[[]]', exec_lua([[return vim.json.encode({{}})]])) - eq('[[],[]]', exec_lua([[return vim.json.encode({{}, {}})]])) - end) - - it('dumps dictionaries', function() - eq('{}', exec_lua([[return vim.json.encode(vim.empty_dict())]])) - eq('{"d":[]}', exec_lua([[return vim.json.encode({d={}})]])) - end) + it('dumps strings', function() + eq('"Test"', exec_lua([[return vim.json.encode('Test')]])) + eq('""', exec_lua([[return vim.json.encode('')]])) + eq('"\\t"', exec_lua([[return vim.json.encode('\t')]])) + eq('"\\n"', exec_lua([[return vim.json.encode('\n')]])) + -- vim.fn.json_encode return \\u001B + eq('"\\u001b"', exec_lua([[return vim.json.encode('\27')]])) + eq('"þÿþ"', exec_lua([[return vim.json.encode('þÿþ')]])) + end) + + it('dumps numbers', function() + eq('0', exec_lua([[return vim.json.encode(0)]])) + eq('10', exec_lua([[return vim.json.encode(10)]])) + eq('-10', exec_lua([[return vim.json.encode(-10)]])) + end) + + it('dumps floats', function() + eq('10.5', exec_lua([[return vim.json.encode(10.5)]])) + eq('-10.5', exec_lua([[return vim.json.encode(-10.5)]])) + eq('-1e-05', exec_lua([[return vim.json.encode(-1e-5)]])) + end) + + it('dumps lists', function() + eq('[]', exec_lua([[return vim.json.encode({})]])) + eq('[[]]', exec_lua([[return vim.json.encode({{}})]])) + eq('[[],[]]', exec_lua([[return vim.json.encode({{}, {}})]])) + end) + + it('dumps dictionaries', function() + eq('{}', exec_lua([[return vim.json.encode(vim.empty_dict())]])) + eq('{"d":[]}', exec_lua([[return vim.json.encode({d={}})]])) + end) it('dumps vim.NIL', function() eq('null', exec_lua([[return vim.json.encode(vim.NIL)]])) diff --git a/test/functional/plugin/lsp/inlay_hint_spec.lua b/test/functional/plugin/lsp/inlay_hint_spec.lua index 103fd8d968..574a4fa5a0 100644 --- a/test/functional/plugin/lsp/inlay_hint_spec.lua +++ b/test/functional/plugin/lsp/inlay_hint_spec.lua @@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local lsp_helpers = require('test.functional.plugin.lsp.helpers') local Screen = require('test.functional.ui.screen') +local eq = helpers.eq local dedent = helpers.dedent local exec_lua = helpers.exec_lua local insert = helpers.insert @@ -65,11 +66,17 @@ describe('inlay hints', function() it( 'inlay hints are applied when vim.lsp.buf.inlay_hint(true) is called', function() - exec_lua([[ - bufnr = vim.api.nvim_get_current_buf() - vim.api.nvim_win_set_buf(0, bufnr) - client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd }) - ]]) + local res = exec_lua([[ + bufnr = vim.api.nvim_get_current_buf() + vim.api.nvim_win_set_buf(0, bufnr) + client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd }) + local client = vim.lsp.get_client_by_id(client_id) + return { + supports_method = client.supports_method("textDocument/inlayHint") + } + ]]) + eq(res, { supports_method = true }) + insert(text) exec_lua([[vim.lsp.buf.inlay_hint(bufnr, true)]]) diff --git a/test/functional/provider/clipboard_spec.lua b/test/functional/provider/clipboard_spec.lua index c8f1518283..0099183302 100644 --- a/test/functional/provider/clipboard_spec.lua +++ b/test/functional/provider/clipboard_spec.lua @@ -211,7 +211,7 @@ describe('clipboard', function() eq('', eval('provider#clipboard#Error()')) end) - it('g:clipboard using VimL functions', function() + it('g:clipboard using Vimscript functions', function() -- Implements a fake clipboard provider. cache_enabled is meaningless here. source([[let g:clipboard = { \ 'name': 'custom', @@ -245,7 +245,7 @@ describe('clipboard', function() eq({{'star', ''}, 'b'}, eval("g:dummy_clipboard_star")) end) - describe('g:clipboard[paste] VimL function', function() + describe('g:clipboard[paste] Vimscript function', function() it('can return empty list for empty clipboard', function() source([[let g:dummy_clipboard = [] let g:clipboard = { diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index a9469bdf2d..dc29b765bd 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -944,6 +944,45 @@ describe('statusline is redrawn on entering cmdline', function() end) end) +it('tabline is not redrawn in Ex mode #24122', function() + clear() + local screen = Screen.new(60, 5) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, reverse = true}, -- MsgSeparator + [2] = {reverse = true}, -- TabLineFill + }) + screen:attach() + + exec([[ + set showtabline=2 + set tabline=%!MyTabLine() + + function! MyTabLine() + + return "foo" + endfunction + ]]) + + feed('gQ') + screen:expect{grid=[[ + {2:foo }| + | + {1: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :^ | + ]]} + + feed('echo 1<CR>') + screen:expect{grid=[[ + {1: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :echo 1 | + 1 | + :^ | + ]]} +end) + describe("cmdline height", function() it("does not crash resized screen #14263", function() clear() diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 91fbbe2579..e8ad0d3f0d 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1587,13 +1587,15 @@ describe('decorations: inline virtual text', function() [9] = {background = Screen.colors.Plum1}; [10] = {foreground = Screen.colors.SlateBlue}; [11] = {blend = 30, background = Screen.colors.Red1}; - [12] = {background = Screen.colors.Yellow1}; + [12] = {background = Screen.colors.Yellow}; [13] = {reverse = true}; [14] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightMagenta}; [15] = {bold = true, reverse = true}; [16] = {foreground = Screen.colors.Red}; [17] = {background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue}; [18] = {background = Screen.colors.LightGrey, foreground = Screen.colors.Red}; + [19] = {background = Screen.colors.Yellow, foreground = Screen.colors.SlateBlue}; + [20] = {background = Screen.colors.LightGrey, foreground = Screen.colors.SlateBlue}; } ns = meths.create_namespace 'test' @@ -1675,9 +1677,11 @@ describe('decorations: inline virtual text', function() | ]]} + meths.buf_set_extmark(0, ns, 0, 5, {virt_text={{''}, {''}}, virt_text_pos='inline'}) meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {': ', 'Special'}, {'string', 'Type'}}, virt_text_pos='inline'}) + feed('V') screen:expect{grid=[[ - ^for _,item in ipairs(items) do | + ^f{7:or _,item in ipairs(items) do} | local text{10:: }{3:string}, hl_id_cell, count = unpack| (item) | if hl_id_cell ~= nil then | @@ -1686,10 +1690,10 @@ describe('decorations: inline virtual text', function() for _ = 1, (count or 1) do | local cell = line[colpos] | cell.text = text | - | + {8:-- VISUAL LINE --} | ]]} - feed('jf,') + feed('<Esc>jf,') screen:expect{grid=[[ for _,item in ipairs(items) do | local text{10:: }{3:string}^, hl_id_cell, count = unpack| @@ -1998,13 +2002,15 @@ bbbbbbb]]) end) it('search highlight is correct', function() - insert('foo foo foo foo') - feed('0') - meths.buf_set_extmark(0, ns, 0, 8, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + insert('foo foo foo foo\nfoo foo foo foo') + feed('gg0') + meths.buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) screen:expect { grid = [[ - ^foo foo {10:virtual text}foo foo | - {1:~ }| + ^foo foo f{10:AAABBB}oo foo | + foo foo f{10:CCCDDD}oo foo | {1:~ }| {1:~ }| {1:~ }| @@ -2017,8 +2023,8 @@ bbbbbbb]]) feed('/foo') screen:expect { grid = [[ - {12:foo} {13:foo} {10:virtual text}{12:foo} {12:foo} | - {1:~ }| + {12:foo} {13:foo} {12:f}{10:AAA}{19:BBB}{12:oo} {12:foo} | + {12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} {12:foo} | {1:~ }| {1:~ }| {1:~ }| @@ -2031,14 +2037,16 @@ bbbbbbb]]) end) it('visual select highlight is correct', function() - insert('foo foo foo foo') - feed('0') - meths.buf_set_extmark(0, ns, 0, 8, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + insert('foo foo foo foo\nfoo foo foo foo') + feed('gg0') + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) feed('8l') screen:expect { grid = [[ - foo foo {10:virtual text}^foo foo | - {1:~ }| + foo foo {10:AAABBB}^foo foo | + foo foo {10:CCCDDD}foo foo | {1:~ }| {1:~ }| {1:~ }| @@ -2049,11 +2057,11 @@ bbbbbbb]]) | ]]} - feed('v') - feed('2h') + feed('<C-V>') + feed('2hj') screen:expect { grid = [[ - foo fo^o{7: }{10:virtual text}{7:f}oo foo | - {1:~ }| + foo fo{7:o }{10:AAA}{20:BBB}{7:f}oo foo | + foo fo^o{7: }{20:CCC}{10:DDD}{7:f}oo foo | {1:~ }| {1:~ }| {1:~ }| @@ -2061,7 +2069,7 @@ bbbbbbb]]) {1:~ }| {1:~ }| {1:~ }| - {8:-- VISUAL --} | + {8:-- VISUAL BLOCK --} | ]]} end) @@ -2214,6 +2222,51 @@ bbbbbbb]]) ]]} end) + it('hidden virtual text does not interfere with Visual highlight', function() + insert('abcdef') + command('set nowrap') + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'XXX', 'Special' } }, virt_text_pos = 'inline' }) + feed('V2zl') + screen:expect{grid=[[ + {10:X}{7:abcde}^f | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {8:-- VISUAL LINE --} | + ]]} + feed('zl') + screen:expect{grid=[[ + {7:abcde}^f | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {8:-- VISUAL LINE --} | + ]]} + feed('zl') + screen:expect{grid=[[ + {7:bcde}^f | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {8:-- VISUAL LINE --} | + ]]} + end) + it('highlighting is correct when virtual text wraps with number', function() insert([[ test @@ -2269,6 +2322,38 @@ bbbbbbb]]) ]]} end) + it('smoothscroll works correctly when virtual text wraps', function() + insert('foobar') + meths.buf_set_extmark(0, ns, 0, 3, + { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) + command('setlocal smoothscroll') + screen:expect{grid=[[ + foo{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:XXXXXXXX}ba^r | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + feed('<C-E>') + screen:expect{grid=[[ + {1:<<<}{10:XXXXX}ba^r | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + it('in diff mode is highlighted correct', function() insert([[ 9000 @@ -2277,9 +2362,11 @@ bbbbbbb]]) 9000 0009 ]]) + insert('aaa\tbbb') command("set diff") - meths.buf_set_extmark(0, ns, 0, 1, - { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + meths.buf_set_extmark(0, ns, 5, 0, { virt_text = { { '!', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 5, 3, { virt_text = { { '' } }, virt_text_pos = 'inline' }) command("vnew") insert([[ 000 @@ -2288,6 +2375,7 @@ bbbbbbb]]) 000 000 ]]) + insert('aaabbb') command("set diff") feed('gg0') screen:expect { grid = [[ @@ -2296,12 +2384,26 @@ bbbbbbb]]) {9:000 }│{9:000}{5:9}{9: }| {9:000 }│{5:9}{9:000 }| {9:000 }│{9:000}{5:9}{9: }| - │ | + {9:aaabbb }│{14:!}{9:aaa}{5: }{9:bbb }| {1:~ }│{1:~ }| {1:~ }│{1:~ }| {15:[No Name] [+] }{13:[No Name] [+] }| | ]]} + command('wincmd w | set nowrap') + feed('zl') + screen:expect { grid = [[ + {9:000 }│{14:test}{9:000 }| + {9:000 }│{9:00}{5:9}{9: }| + {9:000 }│{9:00}{5:9}{9: }| + {9:000 }│{9:000 }| + {9:000 }│{9:00}{5:9}{9: }| + {9:aaabbb }│{9:aaa}{5: }{9:bb^b }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {13:[No Name] [+] }{15:[No Name] [+] }| + | + ]]} end) it('correctly draws when there are multiple overlapping virtual texts on the same line with nowrap', function() @@ -2404,6 +2506,28 @@ bbbbbbb]]) | ]]} end) + + it('list "extends" is drawn with only inline virtual text offscreen', function() + command('set nowrap') + command('set list') + command('set listchars+=extends:c') + meths.buf_set_extmark(0, ns, 0, 0, + { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline' }) + insert(string.rep('a', 50)) + feed('gg0') + screen:expect { grid = [[ + ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:c}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 68a7c89b32..71b9e49d2f 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -2453,6 +2453,86 @@ describe("folded lines", function() ]]) end end) + + it('do not show search or match highlight #24084', function() + insert([[ + line 1 + line 2 + line 3 + line 4]]) + command('2,3fold') + feed('/line') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {2:line} 1 | + {5:+-- 2 lines: line 2·························}| + {6:line} 4 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + /line^ | + ]]) + else + screen:expect([[ + {2:line} 1 | + {5:+-- 2 lines: line 2·························}| + {6:line} 4 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + /line^ | + ]]) + end + feed('<Esc>') + funcs.matchadd('Search', 'line') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {6:line} 1 | + {5:+-- 2 lines: line 2·························}| + {6:line} ^4 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + {6:line} 1 | + {5:+-- 2 lines: line 2·························}| + {6:line} ^4 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end + end) end describe("with ext_multigrid", function() diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua index bd9f7e5381..e1179d29cc 100644 --- a/test/functional/vimscript/input_spec.lua +++ b/test/functional/vimscript/input_spec.lua @@ -552,7 +552,7 @@ describe('confirm()', function() feed(':silent edit foo<cr>') check_and_clear(':silent edit foo |\n') - -- With API (via eval/VimL) call and shortmess+=F + -- With API (via eval/Vimscript) call and shortmess+=F feed(':call nvim_command("edit x")<cr>') check_and_clear(':call nvim_command("edit |\n') diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 4d650fd4ec..5acf16514f 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -697,6 +697,7 @@ let s:filename_checks = { \ 'zimbu': ['file.zu'], \ 'zimbutempl': ['file.zut'], \ 'zir': ['file.zir'], + \ 'zserio': ['file.zs'], \ 'zsh': ['.zprofile', '/etc/zprofile', '.zfbfmarks', 'file.zsh', '.zcompdump', '.zlogin', '.zlogout', '.zshenv', '.zshrc', '.zcompdump-file', '.zlog', '.zlog-file', '.zsh', '.zsh-file', 'any/etc/zprofile', 'zlog', 'zlog-file', 'zsh', 'zsh-file'], \ \ 'help': [$VIMRUNTIME . '/doc/help.txt'], |