diff options
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/core/startup_spec.lua | 22 | ||||
-rw-r--r-- | test/functional/eval/null_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ex_cmds/packadd_spec.lua | 74 | ||||
-rw-r--r-- | test/functional/fixtures/pack/foo/opt/bonus/autoload/bonus.vim | 3 | ||||
-rw-r--r-- | test/functional/fixtures/pack/foo/opt/bonus/lua/bonus.lua | 1 | ||||
-rw-r--r-- | test/functional/fixtures/pack/foo/start/bar/autoload/bar.vim | 3 | ||||
-rw-r--r-- | test/functional/fixtures/pack/foo/start/bar/lua/bar.lua | 1 | ||||
-rw-r--r-- | test/functional/helpers.lua | 8 | ||||
-rw-r--r-- | test/functional/legacy/055_list_and_dict_types_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/legacy/cmdline_spec.lua | 66 | ||||
-rw-r--r-- | test/functional/lua/overrides_spec.lua | 113 | ||||
-rw-r--r-- | test/functional/lua/treesitter_spec.lua | 22 | ||||
-rw-r--r-- | test/functional/ui/cmdline_spec.lua | 32 | ||||
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 142 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 4 |
15 files changed, 251 insertions, 246 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 9b0668f9e6..3bfae5f3d7 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -7,6 +7,7 @@ local ok = helpers.ok local eq = helpers.eq local matches = helpers.matches local eval = helpers.eval +local exec_lua = helpers.exec_lua local feed = helpers.feed local funcs = helpers.funcs local mkdir = helpers.mkdir @@ -305,6 +306,27 @@ describe('startup', function() '+q' }) eq('[\'+q\'] 1', out) end) + + local function pack_clear(cmd) + clear('--cmd', 'set packpath=test/functional/fixtures', '--cmd', cmd) + end + + + it("handles &packpath during startup", function() + pack_clear [[ let g:x = bar#test() ]] + eq(-3, eval 'g:x') + + pack_clear [[ lua _G.y = require'bar'.doit() ]] + eq(9003, exec_lua [[ return _G.y ]]) + end) + + it("handles :packadd during startup", function() + pack_clear [[ packadd! bonus | let g:x = bonus#secret() ]] + eq('halloj', eval 'g:x') + + pack_clear [[ packadd! bonus | lua _G.y = require'bonus'.launch() ]] + eq('CPE 1704 TKS', exec_lua [[ return _G.y ]]) + end) end) describe('sysinit', function() diff --git a/test/functional/eval/null_spec.lua b/test/functional/eval/null_spec.lua index db0a706319..fa8f7d873f 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -132,7 +132,7 @@ describe('NULL', function() end) describe('dict', function() it('does not crash when indexing NULL dict', function() - eq('\nE716: Key not present in Dictionary: test\nE15: Invalid expression: v:_null_dict.test', + eq('\nE716: Key not present in Dictionary: "test"\nE15: Invalid expression: v:_null_dict.test', redir_exec('echo v:_null_dict.test')) end) null_expr_test('makes extend error out', 'extend(D, {})', 'E742: Cannot change value of extend() argument', 0) diff --git a/test/functional/ex_cmds/packadd_spec.lua b/test/functional/ex_cmds/packadd_spec.lua deleted file mode 100644 index 2b0810cf9b..0000000000 --- a/test/functional/ex_cmds/packadd_spec.lua +++ /dev/null @@ -1,74 +0,0 @@ -local helpers = require('test.functional.helpers')(after_each) - -local clear = helpers.clear -local eq = helpers.eq -local exec_lua = helpers.exec_lua - -describe('packadd', function() - before_each(function() - -- Primarily taken from test/functional/legacy/packadd_spec.lua - clear() - exec_lua [[ - TopDirectory = vim.fn.expand(vim.fn.getcwd() .. '/Xdir_lua') - PlugDirectory = TopDirectory .. '/pack/mine/opt/mytest' - - vim.o.packpath = TopDirectory - - function FindPathsContainingDir(dir) - return vim.fn.filter( - vim.split(package.path, ';'), - function(k, v) - return string.find(v, 'mytest') ~= nil - end - ) - end - ]] - end) - - after_each(function() - exec_lua [[ - vim.fn.delete(TopDirectory, 'rf') - ]] - end) - - it('should immediately update package.path in lua', function() - local count_of_paths = exec_lua [[ - vim.fn.mkdir(PlugDirectory .. '/lua/', 'p') - - local num_paths_before = #FindPathsContainingDir('mytest') - - vim.cmd("packadd mytest") - - local num_paths_after = #FindPathsContainingDir('mytest') - - return { num_paths_before, num_paths_after } - ]] - - eq({0, 2}, count_of_paths) - end) - - it('should immediately update package.path in lua even if lua directory does not exist', function() - local count_of_paths = exec_lua [[ - vim.fn.mkdir(PlugDirectory .. '/plugin/', 'p') - - local num_paths_before = #FindPathsContainingDir('mytest') - - vim.cmd("packadd mytest") - - local num_paths_after = #FindPathsContainingDir('mytest') - - return { num_paths_before, num_paths_after } - ]] - - eq({0, 2}, count_of_paths) - end) - - it('should error for invalid paths', function() - local count_of_paths = exec_lua [[ - local ok, err = pcall(vim.cmd, "packadd asdf") - return ok - ]] - - eq(false, count_of_paths) - end) -end) diff --git a/test/functional/fixtures/pack/foo/opt/bonus/autoload/bonus.vim b/test/functional/fixtures/pack/foo/opt/bonus/autoload/bonus.vim new file mode 100644 index 0000000000..5ed8b1b887 --- /dev/null +++ b/test/functional/fixtures/pack/foo/opt/bonus/autoload/bonus.vim @@ -0,0 +1,3 @@ +func bonus#secret() + return "halloj" +endfunc diff --git a/test/functional/fixtures/pack/foo/opt/bonus/lua/bonus.lua b/test/functional/fixtures/pack/foo/opt/bonus/lua/bonus.lua new file mode 100644 index 0000000000..52cb0bc118 --- /dev/null +++ b/test/functional/fixtures/pack/foo/opt/bonus/lua/bonus.lua @@ -0,0 +1 @@ +return {launch=function() return "CPE 1704 TKS" end} diff --git a/test/functional/fixtures/pack/foo/start/bar/autoload/bar.vim b/test/functional/fixtures/pack/foo/start/bar/autoload/bar.vim new file mode 100644 index 0000000000..405e7be71c --- /dev/null +++ b/test/functional/fixtures/pack/foo/start/bar/autoload/bar.vim @@ -0,0 +1,3 @@ +func bar#test() + return -3 +endfunc diff --git a/test/functional/fixtures/pack/foo/start/bar/lua/bar.lua b/test/functional/fixtures/pack/foo/start/bar/lua/bar.lua new file mode 100644 index 0000000000..a7e9a61e35 --- /dev/null +++ b/test/functional/fixtures/pack/foo/start/bar/lua/bar.lua @@ -0,0 +1 @@ +return {doit=function() return 9003 end} diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 0bd378d832..d85a6a3cfe 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -751,6 +751,14 @@ module.curbufmeths = module.create_callindex(module.curbuf) module.curwinmeths = module.create_callindex(module.curwin) module.curtabmeths = module.create_callindex(module.curtab) +function module.exec(code) + return module.meths.exec(code, false) +end + +function module.exec_capture(code) + return module.meths.exec(code, true) +end + function module.exec_lua(code, ...) return module.meths.exec_lua(code, {...}) end diff --git a/test/functional/legacy/055_list_and_dict_types_spec.lua b/test/functional/legacy/055_list_and_dict_types_spec.lua index 91ba8bb106..4d71a526c1 100644 --- a/test/functional/legacy/055_list_and_dict_types_spec.lua +++ b/test/functional/legacy/055_list_and_dict_types_spec.lua @@ -229,7 +229,7 @@ describe('list and dictionary types', function() try let n = d[1500] catch - $put =substitute(v:exception, '\v(.{14}).*( \d{4}).*', '\1\2', '') + $put = substitute(v:exception, '\v(.{14}).*( \"\d{4}\").*', '\1\2', '') endtry " Lookup each items. for i in range(1500) @@ -260,7 +260,7 @@ describe('list and dictionary types', function() expect([[ 3000 2900 2001 1600 1501 - Vim(let):E716: 1500 + Vim(let):E716: "1500" NONE 2999 33=999 {'33': 999}]]) diff --git a/test/functional/legacy/cmdline_spec.lua b/test/functional/legacy/cmdline_spec.lua new file mode 100644 index 0000000000..9ebe9aeb91 --- /dev/null +++ b/test/functional/legacy/cmdline_spec.lua @@ -0,0 +1,66 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local clear = helpers.clear +local feed = helpers.feed +local feed_command = helpers.feed_command +local source = helpers.source + +describe('cmdline', function() + before_each(clear) + + it('is cleared when switching tabs', function() + local screen = Screen.new(30, 10) + screen:attach() + feed_command([[call setline(1, range(30))]]) + screen:expect([[ + ^0 | + 1 | + 2 | + 3 | + 4 | + 5 | + 6 | + 7 | + 8 | + :call setline(1, range(30)) | + ]]) + feed([[:tabnew<cr><C-w>-<C-w>-gtgt]]) + screen:expect([[ + + [No Name] [No Name] X| + ^ | + ~ | + ~ | + ~ | + ~ | + ~ | + 6 | + 7 | + | + ]]) + end) + + it('prints every executed Ex command if verbose >= 16', function() + local screen = Screen.new(60, 12) + screen:attach() + source([[ + command DoSomething echo 'hello' |set ts=4 |let v = '123' |echo v + call feedkeys("\r", 't') " for the hit-enter prompt + set verbose=20 + ]]) + feed_command('DoSomething') + screen:expect([[ + | + ~ | + ~ | + | + Executing: DoSomething | + Executing: echo 'hello' |set ts=4 |let v = '123' |echo v | + hello | + Executing: set ts=4 |let v = '123' |echo v | + Executing: let v = '123' |echo v | + Executing: echo v | + 123 | + Press ENTER or type command to continue^ | + ]]) + end) +end) diff --git a/test/functional/lua/overrides_spec.lua b/test/functional/lua/overrides_spec.lua index 1bccc02847..5fbba63736 100644 --- a/test/functional/lua/overrides_spec.lua +++ b/test/functional/lua/overrides_spec.lua @@ -285,119 +285,6 @@ describe('debug.debug', function() end) end) -describe('package.path/package.cpath', function() - local sl = alter_slashes - - local function get_new_paths(sufs, runtimepaths) - runtimepaths = runtimepaths or meths.list_runtime_paths() - local new_paths = {} - local sep = package.config:sub(1, 1) - for _, v in ipairs(runtimepaths) do - for _, suf in ipairs(sufs) do - new_paths[#new_paths + 1] = v .. sep .. 'lua' .. suf - end - end - return new_paths - end - local function eval_lua(expr, ...) - return meths.exec_lua('return '..expr, {...}) - end - local function set_path(which, value) - return exec_lua('package[select(1, ...)] = select(2, ...)', which, value) - end - - it('contains directories from &runtimepath on first invocation', function() - local new_paths = get_new_paths(sl{'/?.lua', '/?/init.lua'}) - local new_paths_str = table.concat(new_paths, ';') - eq(new_paths_str, eval_lua('package.path'):sub(1, #new_paths_str)) - - local new_cpaths = get_new_paths(iswin() and {'\\?.dll'} or {'/?.so'}) - local new_cpaths_str = table.concat(new_cpaths, ';') - eq(new_cpaths_str, eval_lua('package.cpath'):sub(1, #new_cpaths_str)) - end) - it('puts directories from &runtimepath always at the start', function() - meths.set_option('runtimepath', 'a,b') - local new_paths = get_new_paths(sl{'/?.lua', '/?/init.lua'}, {'a', 'b'}) - local new_paths_str = table.concat(new_paths, ';') - eq(new_paths_str, eval_lua('package.path'):sub(1, #new_paths_str)) - - set_path('path', sl'foo/?.lua;foo/?/init.lua;' .. new_paths_str) - - neq(new_paths_str, eval_lua('package.path'):sub(1, #new_paths_str)) - - command('set runtimepath+=c') - new_paths = get_new_paths(sl{'/?.lua', '/?/init.lua'}, {'a', 'b', 'c'}) - new_paths_str = table.concat(new_paths, ';') - eq(new_paths_str, eval_lua('package.path'):sub(1, #new_paths_str)) - end) - it('understands uncommon suffixes', function() - set_path('cpath', './?/foo/bar/baz/x.nlua') - meths.set_option('runtimepath', 'a') - local new_paths = get_new_paths({'/?/foo/bar/baz/x.nlua'}, {'a'}) - local new_paths_str = table.concat(new_paths, ';') - eq(new_paths_str, eval_lua('package.cpath'):sub(1, #new_paths_str)) - - set_path('cpath', './yyy?zzz/x') - meths.set_option('runtimepath', 'b') - new_paths = get_new_paths({'/yyy?zzz/x'}, {'b'}) - new_paths_str = table.concat(new_paths, ';') - eq(new_paths_str, eval_lua('package.cpath'):sub(1, #new_paths_str)) - - set_path('cpath', './yyy?zzz/123?ghi/x') - meths.set_option('runtimepath', 'b') - new_paths = get_new_paths({'/yyy?zzz/123?ghi/x'}, {'b'}) - new_paths_str = table.concat(new_paths, ';') - eq(new_paths_str, eval_lua('package.cpath'):sub(1, #new_paths_str)) - end) - it('preserves empty items', function() - local many_empty_path = ';;;;;;' - local many_empty_cpath = ';;;;;;./?.luaso' - set_path('path', many_empty_path) - set_path('cpath', many_empty_cpath) - meths.set_option('runtimepath', 'a') - local new_paths = get_new_paths(sl{'/?.lua', '/?/init.lua'}, {'a'}) - local new_paths_str = table.concat(new_paths, ';') - eq(new_paths_str .. ';' .. many_empty_path, eval_lua('package.path')) - local new_cpaths = get_new_paths({'/?.luaso'}, {'a'}) - local new_cpaths_str = table.concat(new_cpaths, ';') - eq(new_cpaths_str .. ';' .. many_empty_cpath, eval_lua('package.cpath')) - end) - it('preserves empty value', function() - set_path('path', '') - meths.set_option('runtimepath', 'a') - local new_paths = get_new_paths(sl{'/?.lua', '/?/init.lua'}, {'a'}) - local new_paths_str = table.concat(new_paths, ';') - eq(new_paths_str .. ';', eval_lua('package.path')) - end) - it('purges out all additions if runtimepath is set to empty', function() - local new_paths = get_new_paths(sl{'/?.lua', '/?/init.lua'}) - local new_paths_str = table.concat(new_paths, ';') - local path = eval_lua('package.path') - eq(new_paths_str, path:sub(1, #new_paths_str)) - - local new_cpaths = get_new_paths(iswin() and {'\\?.dll'} or {'/?.so'}) - local new_cpaths_str = table.concat(new_cpaths, ';') - local cpath = eval_lua('package.cpath') - eq(new_cpaths_str, cpath:sub(1, #new_cpaths_str)) - - meths.set_option('runtimepath', '') - eq(path:sub(#new_paths_str + 2, -1), eval_lua('package.path')) - eq(cpath:sub(#new_cpaths_str + 2, -1), eval_lua('package.cpath')) - end) - it('works with paths with escaped commas', function() - meths.set_option('runtimepath', '\\,') - local new_paths = get_new_paths(sl{'/?.lua', '/?/init.lua'}, {','}) - local new_paths_str = table.concat(new_paths, ';') - eq(new_paths_str, eval_lua('package.path'):sub(1, #new_paths_str)) - end) - it('ignores paths with semicolons', function() - meths.set_option('runtimepath', 'foo;bar,\\,') - local new_paths = get_new_paths(sl{'/?.lua', '/?/init.lua'}, {','}) - local new_paths_str = table.concat(new_paths, ';') - eq(new_paths_str, eval_lua('package.path'):sub(1, #new_paths_str)) - end) -end) - describe('os.getenv', function() it('returns nothing for undefined env var', function() eq(NIL, funcs.luaeval('os.getenv("XTEST_1")')) diff --git a/test/functional/lua/treesitter_spec.lua b/test/functional/lua/treesitter_spec.lua index 3526b64395..9eb5c8b1dd 100644 --- a/test/functional/lua/treesitter_spec.lua +++ b/test/functional/lua/treesitter_spec.lua @@ -80,13 +80,6 @@ describe('treesitter API with C parser', function() eq({1,2,1,12}, exec_lua("return {descendant:range()}")) eq("(declaration type: (primitive_type) declarator: (init_declarator declarator: (identifier) value: (number_literal)))", exec_lua("return descendant:sexpr()")) - eq(true, exec_lua("return child == child")) - -- separate lua object, but represents same node - eq(true, exec_lua("return child == root:child(0)")) - eq(false, exec_lua("return child == descendant2")) - eq(false, exec_lua("return child == nil")) - eq(false, exec_lua("return child == tree")) - feed("2G7|ay") exec_lua([[ tree2 = parser:parse() @@ -98,6 +91,21 @@ describe('treesitter API with C parser', function() eq("<node declaration>", exec_lua("return tostring(descendant2)")) eq({1,2,1,13}, exec_lua("return {descendant2:range()}")) + eq(true, exec_lua("return child == child")) + -- separate lua object, but represents same node + eq(true, exec_lua("return child == root:child(0)")) + eq(false, exec_lua("return child == descendant2")) + eq(false, exec_lua("return child == nil")) + eq(false, exec_lua("return child == tree")) + + eq("string", exec_lua("return type(child:id())")) + eq(true, exec_lua("return child:id() == child:id()")) + -- separate lua object, but represents same node + eq(true, exec_lua("return child:id() == root:child(0):id()")) + eq(false, exec_lua("return child:id() == descendant2:id()")) + eq(false, exec_lua("return child:id() == nil")) + eq(false, exec_lua("return child:id() == tree")) + -- orginal tree did not change eq({1,2,1,12}, exec_lua("return {descendant:range()}")) diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 01f0d8a4d7..21c01b3458 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -3,7 +3,6 @@ local Screen = require('test.functional.ui.screen') local clear, feed = helpers.clear, helpers.feed local source = helpers.source local command = helpers.command -local feed_command = helpers.feed_command local function new_screen(opt) local screen = Screen.new(25, 5) @@ -843,34 +842,3 @@ describe('cmdline redraw', function() ]], unchanged=true} end) end) - -describe('cmdline', function() - before_each(function() - clear() - end) - - it('prints every executed Ex command if verbose >= 16', function() - local screen = Screen.new(50, 12) - screen:attach() - source([[ - command DoSomething echo 'hello' |set ts=4 |let v = '123' |echo v - call feedkeys("\r", 't') " for the hit-enter prompt - set verbose=20 - ]]) - feed_command('DoSomething') - screen:expect([[ - | - ~ | - | - Executing: DoSomething | - Executing: echo 'hello' |set ts=4 |let v = '123' || - echo v | - hello | - Executing: set ts=4 |let v = '123' |echo v | - Executing: let v = '123' |echo v | - Executing: echo v | - 123 | - Press ENTER or type command to continue^ | - ]]) - end) -end) diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 304c5aecb1..4182090732 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -5,20 +5,32 @@ local clear = helpers.clear local feed = helpers.feed local insert = helpers.insert local exec_lua = helpers.exec_lua +local exec = helpers.exec local expect_events = helpers.expect_events +local meths = helpers.meths -describe('decorations provider', function() +describe('decorations providers', function() local screen before_each(function() clear() screen = Screen.new(40, 8) screen:attach() - screen:set_default_attr_ids({ - [1] = {bold=true, foreground=Screen.colors.Blue}, - }) + screen:set_default_attr_ids { + [1] = {bold=true, foreground=Screen.colors.Blue}; + [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}; + [3] = {foreground = Screen.colors.Brown}; + [4] = {foreground = Screen.colors.Blue1}; + [5] = {foreground = Screen.colors.Magenta}; + [6] = {bold = true, foreground = Screen.colors.Brown}; + [7] = {background = Screen.colors.Gray90}; + [8] = {bold = true, reverse = true}; + [9] = {reverse = true}; + [10] = {italic = true, background = Screen.colors.Magenta}; + [11] = {foreground = Screen.colors.Red, background = tonumber('0x005028')}; + } end) - local mudholland = [[ + local mulholland = [[ // just to see if there was an accident // on Mulholland Drive try_start(); @@ -28,21 +40,21 @@ describe('decorations provider', function() restore_buffer(&save_buf); ]] local function setup_provider(code) - exec_lua ([[ + return exec_lua ([[ local a = vim.api - test1 = a.nvim_create_namespace "test1" + _G.ns1 = a.nvim_create_namespace "ns1" ]] .. (code or [[ beamtrace = {} - function on_do(kind, ...) + local function on_do(kind, ...) table.insert(beamtrace, {kind, ...}) end ]]) .. [[ - a.nvim_set_decoration_provider( - test1, { + a.nvim_set_decoration_provider(_G.ns1, { on_start = on_do; on_buf = on_do; on_win = on_do; on_line = on_do; on_end = on_do; }) + return _G.ns1 ]]) end @@ -51,8 +63,8 @@ describe('decorations provider', function() expect_events(expected, actual, "beam trace") end - it('leaves a trace', function() - insert(mudholland) + it('leave a trace', function() + insert(mulholland) setup_provider() @@ -99,11 +111,12 @@ describe('decorations provider', function() } end) - it('single provider', function() - insert(mudholland) + it('can have single provider', function() + insert(mulholland) setup_provider [[ local hl = a.nvim_get_hl_id_by_name "ErrorMsg" - function do_it(event, ...) + local test_ns = a.nvim_create_namespace "mulholland" + function on_do(event, ...) if event == "line" then local win, buf, line = ... a.nvim_buf_set_extmark(buf, test_ns, line, line, @@ -114,5 +127,104 @@ describe('decorations provider', function() end end ]] + + screen:expect{grid=[[ + {2:/}/ just to see if there was an accident | + /{2:/} on Mulholland Drive | + tr{2:y}_start(); | + buf{2:r}ef_T save_buf; | + swit{2:c}h_buffer(&save_buf, buf); | + posp {2:=} getmark(mark, false); | + restor{2:e}_buffer(&save_buf);^ | + | + ]]} + end) + + it('can predefine highlights', function() + screen:try_resize(40, 16) + insert(mulholland) + exec [[ + 3 + set ft=c + syntax on + set number cursorline + split + ]] + local ns1 = setup_provider() + + for k,v in pairs { + LineNr = {italic=true, bg="Magenta"}; + Comment = {fg="#FF0000", bg = 80*256+40}; + CursorLine = {link="ErrorMsg"}; + } do meths.set_hl(ns1, k, v) end + + screen:expect{grid=[[ + {3: 1 }{4:// just to see if there was an accid}| + {3: }{4:ent} | + {3: 2 }{4:// on Mulholland Drive} | + {6: 3 }{7:^try_start(); }| + {3: 4 }bufref_T save_buf; | + {3: 5 }switch_buffer(&save_buf, buf); | + {3: 6 }posp = getmark(mark, {5:false}); | + {8:[No Name] [+] }| + {3: 2 }{4:// on Mulholland Drive} | + {6: 3 }{7:try_start(); }| + {3: 4 }bufref_T save_buf; | + {3: 5 }switch_buffer(&save_buf, buf); | + {3: 6 }posp = getmark(mark, {5:false}); | + {3: 7 }restore_buffer(&save_buf); | + {9:[No Name] [+] }| + | + ]]} + + meths.set_hl_ns(ns1) + screen:expect{grid=[[ + {10: 1 }{11:// just to see if there was an accid}| + {10: }{11:ent} | + {10: 2 }{11:// on Mulholland Drive} | + {6: 3 }{2:^try_start(); }| + {10: 4 }bufref_T save_buf; | + {10: 5 }switch_buffer(&save_buf, buf); | + {10: 6 }posp = getmark(mark, {5:false}); | + {8:[No Name] [+] }| + {10: 2 }{11:// on Mulholland Drive} | + {6: 3 }{2:try_start(); }| + {10: 4 }bufref_T save_buf; | + {10: 5 }switch_buffer(&save_buf, buf); | + {10: 6 }posp = getmark(mark, {5:false}); | + {10: 7 }restore_buffer(&save_buf); | + {9:[No Name] [+] }| + | + ]]} + + exec_lua [[ + local a = vim.api + local thewin = a.nvim_get_current_win() + local ns2 = a.nvim_create_namespace 'ns2' + a.nvim_set_decoration_provider (ns2, { + on_win = function (_, win, buf) + a.nvim_set_hl_ns(win == thewin and _G.ns1 or ns2) + end; + }) + ]] + screen:expect{grid=[[ + {10: 1 }{11:// just to see if there was an accid}| + {10: }{11:ent} | + {10: 2 }{11:// on Mulholland Drive} | + {6: 3 }{2:^try_start(); }| + {10: 4 }bufref_T save_buf; | + {10: 5 }switch_buffer(&save_buf, buf); | + {10: 6 }posp = getmark(mark, {5:false}); | + {8:[No Name] [+] }| + {3: 2 }{4:// on Mulholland Drive} | + {6: 3 }{7:try_start(); }| + {3: 4 }bufref_T save_buf; | + {3: 5 }switch_buffer(&save_buf, buf); | + {3: 6 }posp = getmark(mark, {5:false}); | + {3: 7 }restore_buffer(&save_buf); | + {9:[No Name] [+] }| + | + ]]} + end) end) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index bf979e89f4..8fa9fcc42f 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -1289,7 +1289,7 @@ local function fmt_ext_state(name, state) for k,v in pairs(state) do str = (str.." ["..k.."] = {win = {id = "..v.win.id.."}, topline = " ..v.topline..", botline = "..v.botline..", curline = "..v.curline - ..", curcol = "..v.curcol.."},\n") + ..", curcol = "..v.curcol.."};\n") end return str .. "}" else @@ -1316,7 +1316,7 @@ function Screen:print_snapshot(attrs, ignore) dict = "{"..self:_pprint_attrs(a).."}" end local keyval = (type(i) == "number") and "["..tostring(i).."]" or i - table.insert(attrstrs, " "..keyval.." = "..dict..",") + table.insert(attrstrs, " "..keyval.." = "..dict..";") end attrstr = (", attr_ids={\n"..table.concat(attrstrs, "\n").."\n}") end |