diff options
author | Rom Grk <romgrk.cc@gmail.com> | 2020-11-03 03:11:08 -0500 |
---|---|---|
committer | Rom Grk <romgrk.cc@gmail.com> | 2020-11-03 03:11:08 -0500 |
commit | 13e0ca3e194a438383b8451e19090355aa6c29dc (patch) | |
tree | 0ac33ef5ac829b7c74dd15f34b17540c3186c356 /test/functional/ui | |
parent | c7c865214655f7d88fde85ed4947f07319c14182 (diff) | |
parent | 5b5848f2fb1f4b7995bb8a59d94b6766d2182070 (diff) | |
download | rneovim-13e0ca3e194a438383b8451e19090355aa6c29dc.tar.gz rneovim-13e0ca3e194a438383b8451e19090355aa6c29dc.tar.bz2 rneovim-13e0ca3e194a438383b8451e19090355aa6c29dc.zip |
Merge branch 'master' into add-scroll-events
Diffstat (limited to 'test/functional/ui')
-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/popupmenu_spec.lua | 44 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 4 |
4 files changed, 151 insertions, 71 deletions
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/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index c1c5d1ce2e..3f984ff943 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -1213,10 +1213,10 @@ describe('builtin popupmenu', function() funcs.complete(29, {'word', 'choice', 'text', 'thing'}) screen:expect([[ some long prefix before the ^ | - {n:word }{1: }| - {n:choice }{1: }| - {n:text }{1: }| - {n:thing }{1: }| + {1:~ }{n: word }| + {1:~ }{n: choice}| + {1:~ }{n: text }| + {1:~ }{n: thing }| {1:~ }| {1:~ }| {1:~ }| @@ -1261,10 +1261,10 @@ describe('builtin popupmenu', function() feed('<c-p>') screen:expect([[ some long prefix before the text| - {n:^word }{1: }| - {n:choice }{1: }| - {s:text }{1: }| - {n:thing }{1: }| + {1:^~ }{n: word }| + {1:~ }{n: choice}| + {1:~ }{s: text }| + {1:~ }{n: thing }| {1:~ }| {1:~ }| {1:~ }| @@ -1341,10 +1341,10 @@ describe('builtin popupmenu', function() screen:expect([[ some long prefix | before the text^ | - {1:~ }{n: word }| - {1:~ }{n: choice }| - {1:~ }{s: text }| - {1:~ }{n: thing }| + {1:~ }{n: word }{1: }| + {1:~ }{n: choice }{1: }| + {1:~ }{s: text }{1: }| + {1:~ }{n: thing }{1: }| {1:~ }| {2:-- INSERT --} | ]]) @@ -1358,10 +1358,10 @@ describe('builtin popupmenu', function() funcs.complete(29, {'word', 'choice', 'text', 'thing'}) screen:expect([[ some long prefix before the ^ | - {n:word }{1: }| - {n:choice }{1: }| - {n:text }{1: }| - {n:thing }{1: }| + {1:~ }{n: word }| + {1:~ }{n: choice}| + {1:~ }{n: text }| + {1:~ }{n: thing }| {1:~ }| {1:~ }| {1:~ }| @@ -2168,8 +2168,8 @@ describe('builtin popupmenu', function() funcs.complete(29, {'word', 'choice', 'text', 'thing'}) screen:expect([[ some long prefix before the ^ | - {n:word }{c: }{1: }| - {n:choice }{s: }{1: }| + {1:~ }{n: word }{c: }| + {1:~ }{n: choice}{s: }| {1:~ }| {1:~ }| {1:~ }| @@ -2187,10 +2187,10 @@ describe('builtin popupmenu', function() funcs.complete(29, {'word', 'choice', 'text', 'thing'}) screen:expect([[ some long prefix before the ^ | - {n:word }{1: }| - {n:choice }{1: }| - {n:text }{1: }| - {n:thing }{1: }| + {1:~ }{n: word }| + {1:~ }{n: choice}| + {1:~ }{n: text }| + {1:~ }{n: thing }| {1:~ }| {1:~ }| {2:-- INSERT --} | 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 |