diff options
author | Josh Rahm <rahm@google.com> | 2022-07-18 19:37:18 +0000 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2022-07-18 19:37:18 +0000 |
commit | 308e1940dcd64aa6c344c403d4f9e0dda58d9c5c (patch) | |
tree | 35fe43e01755e0f312650667004487a44d6b7941 /test/functional/ui/screen_basic_spec.lua | |
parent | 96a00c7c588b2f38a2424aeeb4ea3581d370bf2d (diff) | |
parent | e8c94697bcbe23a5c7b07c292b90a6b70aadfa87 (diff) | |
download | rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.tar.gz rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.tar.bz2 rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.zip |
Merge remote-tracking branch 'upstream/master' into rahm
Diffstat (limited to 'test/functional/ui/screen_basic_spec.lua')
-rw-r--r-- | test/functional/ui/screen_basic_spec.lua | 250 |
1 files changed, 152 insertions, 98 deletions
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 958e137f65..6c872e52d3 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -6,6 +6,7 @@ local insert = helpers.insert local eq = helpers.eq local eval = helpers.eval local iswin = helpers.iswin +local funcs, meths, exec_lua = helpers.funcs, helpers.meths, helpers.exec_lua describe('screen', function() local screen @@ -127,14 +128,67 @@ local function screen_tests(linegrid) end) it('has correct default title with named file', function() - local expected = (iswin() and 'myfile (C:\\mydir) - NVIM' - or 'myfile (/mydir) - NVIM') + local expected = (iswin() and 'myfile (C:\\mydir) - NVIM' or 'myfile (/mydir) - NVIM') command('set title') command(iswin() and 'file C:\\mydir\\myfile' or 'file /mydir/myfile') screen:expect(function() eq(expected, screen.title) end) end) + + describe('is not changed by', function() + local file1 = iswin() and 'C:\\mydir\\myfile1' or '/mydir/myfile1' + local file2 = iswin() and 'C:\\mydir\\myfile2' or '/mydir/myfile2' + local expected = (iswin() and 'myfile1 (C:\\mydir) - NVIM' or 'myfile1 (/mydir) - NVIM') + local buf2 + + before_each(function() + command('edit '..file1) + buf2 = funcs.bufadd(file2) + command('set title') + end) + + it('calling setbufvar() to set an option in a hidden buffer from i_CTRL-R', function() + command([[inoremap <F2> <C-R>=setbufvar(]]..buf2..[[, '&autoindent', 1) ? '' : ''<CR>]]) + feed('i<F2><Esc>') + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('an RPC call to nvim_buf_set_option in a hidden buffer', function() + meths.buf_set_option(buf2, 'autoindent', true) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('a Lua callback calling nvim_buf_set_option in a hidden buffer', function() + exec_lua(string.format([[ + vim.schedule(function() + vim.api.nvim_buf_set_option(%d, 'autoindent', true) + end) + ]], buf2)) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('a Lua callback calling nvim_buf_call in a hidden buffer', function() + exec_lua(string.format([[ + vim.schedule(function() + vim.api.nvim_buf_call(%d, function() end) + end) + ]], buf2)) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + end) end) describe(':set icon', function() @@ -272,12 +326,12 @@ local function screen_tests(linegrid) command('vsp') command('vsp') screen:expect([[ - ^ {3:│} {3:│} | - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| + ^ │ │ | + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| {1:[No Name] }{3:[No Name] [No Name] }| | {0:~ }| @@ -289,12 +343,12 @@ local function screen_tests(linegrid) ]]) insert('hello') screen:expect([[ - hell^o {3:│}hello {3:│}hello | - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| + hell^o │hello │hello | + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| hello | {0:~ }| @@ -315,12 +369,12 @@ local function screen_tests(linegrid) command('vsp') insert('hello') screen:expect([[ - hell^o {3:│}hello {3:│}hello | - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| + hell^o │hello │hello | + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| hello | {0:~ }| @@ -352,12 +406,12 @@ local function screen_tests(linegrid) command('tabprevious') screen:expect([[ {2: }{6:4}{2:+ [No Name] }{4: + [No Name] }{3: }{4:X}| - hell^o {3:│}hello {3:│}hello | - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| - {0:~ }{3:│}{0:~ }{3:│}{0:~ }| + hell^o │hello │hello | + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }| {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| hello | {0:~ }| @@ -466,36 +520,36 @@ local function screen_tests(linegrid) command('vsplit') screen:expect([[ - ^foo {3:│}foo | - foo {3:│}foo | - foo {3:│}foo | - foo {3:│}foo | - foo {3:│}foo | - foo {3:│}foo | - foo {3:│}foo | - foo {3:│}foo | - foo {3:│}foo | - foo {3:│}foo | - foo {3:│}foo | - foo {3:│}foo | + ^foo │foo | + foo │foo | + foo │foo | + foo │foo | + foo │foo | + foo │foo | + foo │foo | + foo │foo | + foo │foo | + foo │foo | + foo │foo | + foo │foo | {1:[No Name] [+] }{3:[No Name] [+] }| | ]]) feed('<PageDown>') screen:expect([[ - ^foo {3:│}foo | - foo {3:│}foo | - foo {3:│}foo | - foo {3:│}foo | - bar {3:│}foo | - bar {3:│}foo | - bar {3:│}foo | - bar {3:│}foo | - bar {3:│}foo | - bar {3:│}foo | - bar {3:│}foo | - bar {3:│}foo | + ^foo │foo | + foo │foo | + foo │foo | + foo │foo | + bar │foo | + bar │foo | + bar │foo | + bar │foo | + bar │foo | + bar │foo | + bar │foo | + bar │foo | {1:[No Name] [+] }{3:[No Name] [+] }| | ]]) @@ -694,12 +748,12 @@ local function screen_tests(linegrid) command('vsp') command('vsp') screen:expect([[ - and {3:│}and {3:│}and | - clearing {3:│}clearing {3:│}clearing | - in {3:│}in {3:│}in | - split {3:│}split {3:│}split | - windows {3:│}windows {3:│}windows | - ^ {3:│} {3:│} | + and │and │and | + clearing │clearing │clearing | + in │in │in | + split │split │split | + windows │windows │windows | + ^ │ │ | {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| clearing | in | @@ -714,12 +768,12 @@ local function screen_tests(linegrid) it('only affects the current scroll region', function() feed('6k') screen:expect([[ - ^scrolling {3:│}and {3:│}and | - and {3:│}clearing {3:│}clearing | - clearing {3:│}in {3:│}in | - in {3:│}split {3:│}split | - split {3:│}windows {3:│}windows | - windows {3:│} {3:│} | + ^scrolling │and │and | + and │clearing │clearing | + clearing │in │in | + in │split │split | + split │windows │windows | + windows │ │ | {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| clearing | in | @@ -731,12 +785,12 @@ local function screen_tests(linegrid) ]]) feed('<c-w>l') screen:expect([[ - scrolling {3:│}and {3:│}and | - and {3:│}clearing {3:│}clearing | - clearing {3:│}in {3:│}in | - in {3:│}split {3:│}split | - split {3:│}windows {3:│}windows | - windows {3:│}^ {3:│} | + scrolling │and │and | + and │clearing │clearing | + clearing │in │in | + in │split │split | + split │windows │windows | + windows │^ │ | {3:[No Name] [+] }{1:[No Name] [+] }{3:<Name] [+] }| clearing | in | @@ -748,12 +802,12 @@ local function screen_tests(linegrid) ]]) feed('gg') screen:expect([[ - scrolling {3:│}^Inserting {3:│}and | - and {3:│}text {3:│}clearing | - clearing {3:│}with {3:│}in | - in {3:│}many {3:│}split | - split {3:│}lines {3:│}windows | - windows {3:│}to {3:│} | + scrolling │^Inserting │and | + and │text │clearing | + clearing │with │in | + in │many │split | + split │lines │windows | + windows │to │ | {3:[No Name] [+] }{1:[No Name] [+] }{3:<Name] [+] }| clearing | in | @@ -765,12 +819,12 @@ local function screen_tests(linegrid) ]]) feed('7j') screen:expect([[ - scrolling {3:│}with {3:│}and | - and {3:│}many {3:│}clearing | - clearing {3:│}lines {3:│}in | - in {3:│}to {3:│}split | - split {3:│}test {3:│}windows | - windows {3:│}^scrolling {3:│} | + scrolling │with │and | + and │many │clearing | + clearing │lines │in | + in │to │split | + split │test │windows | + windows │^scrolling │ | {3:[No Name] [+] }{1:[No Name] [+] }{3:<Name] [+] }| clearing | in | @@ -782,12 +836,12 @@ local function screen_tests(linegrid) ]]) feed('2j') screen:expect([[ - scrolling {3:│}lines {3:│}and | - and {3:│}to {3:│}clearing | - clearing {3:│}test {3:│}in | - in {3:│}scrolling {3:│}split | - split {3:│}and {3:│}windows | - windows {3:│}^clearing {3:│} | + scrolling │lines │and | + and │to │clearing | + clearing │test │in | + in │scrolling │split | + split │and │windows | + windows │^clearing │ | {3:[No Name] [+] }{1:[No Name] [+] }{3:<Name] [+] }| clearing | in | @@ -799,12 +853,12 @@ local function screen_tests(linegrid) ]]) feed('5k') screen:expect([[ - scrolling {3:│}^lines {3:│}and | - and {3:│}to {3:│}clearing | - clearing {3:│}test {3:│}in | - in {3:│}scrolling {3:│}split | - split {3:│}and {3:│}windows | - windows {3:│}clearing {3:│} | + scrolling │^lines │and | + and │to │clearing | + clearing │test │in | + in │scrolling │split | + split │and │windows | + windows │clearing │ | {3:[No Name] [+] }{1:[No Name] [+] }{3:<Name] [+] }| clearing | in | @@ -816,12 +870,12 @@ local function screen_tests(linegrid) ]]) feed('k') screen:expect([[ - scrolling {3:│}^many {3:│}and | - and {3:│}lines {3:│}clearing | - clearing {3:│}to {3:│}in | - in {3:│}test {3:│}split | - split {3:│}scrolling {3:│}windows | - windows {3:│}and {3:│} | + scrolling │^many │and | + and │lines │clearing | + clearing │to │in | + in │test │split | + split │scrolling │windows | + windows │and │ | {3:[No Name] [+] }{1:[No Name] [+] }{3:<Name] [+] }| clearing | in | |