diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/functional/legacy/eval_spec.lua | 2 | ||||
| -rw-r--r-- | test/functional/ui/float_spec.lua | 240 | ||||
| -rw-r--r-- | test/functional/ui/highlight_spec.lua | 40 | ||||
| -rw-r--r-- | test/functional/ui/input_spec.lua | 45 |
4 files changed, 255 insertions, 72 deletions
diff --git a/test/functional/legacy/eval_spec.lua b/test/functional/legacy/eval_spec.lua index 05d853622e..d3c0b4b938 100644 --- a/test/functional/legacy/eval_spec.lua +++ b/test/functional/legacy/eval_spec.lua @@ -46,7 +46,7 @@ describe('eval', function() command('AR "') command([[let @" = "abc\n"]]) source('AR "') - command([[let @" = "abc\<C-m>"]]) + command([[let @" = "abc\r"]]) command('AR "') command([[let @= = '"abc"']]) command('AR =') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 87aa6ffcbe..359d1f206a 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -17,6 +17,7 @@ local funcs = helpers.funcs local run = helpers.run local pcall_err = helpers.pcall_err local tbl_contains = global_helpers.tbl_contains +local curbuf, curwin, curtab = helpers.curbuf, helpers.curwin, helpers.curtab describe('float window', function() before_each(function() @@ -418,12 +419,13 @@ describe('float window', function() eq(winids, eval('winids')) end) - describe('with only one tabpage', function() - local old_buf, old_win + describe('with only one tabpage,', function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1} + local old_buf, old_win before_each(function() - old_buf = meths.get_current_buf() - old_win = meths.get_current_win() + insert('foo') + old_buf = curbuf().id + old_win = curwin().id end) describe('closing the last non-floating window gives E444', function() before_each(function() @@ -440,131 +442,228 @@ describe('float window', function() end) end) describe("deleting the last non-floating window's buffer", function() - before_each(function() - insert('foo') - end) describe('leaves one window with an empty buffer when there is only one buffer', function() + local same_buf_float before_each(function() - meths.open_win(old_buf, true, float_opts) + same_buf_float = meths.open_win(old_buf, false, float_opts).id end) - it('if called from non-floating window', function() - meths.set_current_win(old_win) - meths.buf_delete(old_buf, {force = true}) - eq(old_win, meths.get_current_win()) + after_each(function() + eq(old_win, curwin().id) expect('') eq(1, #meths.list_wins()) end) + it('if called from non-floating window', function() + meths.buf_delete(old_buf, {force = true}) + end) it('if called from floating window', function() + meths.set_current_win(same_buf_float) + command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()') + command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()') meths.buf_delete(old_buf, {force = true}) - eq(old_win, meths.get_current_win()) - expect('') - eq(1, #meths.list_wins()) + eq(same_buf_float, eval('g:win_leave')) + eq(old_win, eval('g:win_enter')) end) end) describe('closes other windows with that buffer when there are other buffers', function() - local same_buf_win, other_buf, other_buf_win + local same_buf_float, other_buf, other_buf_float before_each(function() - same_buf_win = meths.open_win(old_buf, false, float_opts) - other_buf = meths.create_buf(true, false) - other_buf_win = meths.open_win(other_buf, true, float_opts) + same_buf_float = meths.open_win(old_buf, false, float_opts).id + other_buf = meths.create_buf(true, false).id + other_buf_float = meths.open_win(other_buf, true, float_opts).id insert('bar') meths.set_current_win(old_win) end) - it('if called from non-floating window', function() - meths.buf_delete(old_buf, {force = true}) - eq(old_win, meths.get_current_win()) - eq(other_buf, meths.get_current_buf()) + after_each(function() + eq(other_buf, curbuf().id) expect('bar') eq(2, #meths.list_wins()) end) + it('if called from non-floating window', function() + meths.buf_delete(old_buf, {force = true}) + eq(old_win, curwin().id) + end) it('if called from floating window with the same buffer', function() - meths.set_current_win(same_buf_win) + meths.set_current_win(same_buf_float) + command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()') + command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()') meths.buf_delete(old_buf, {force = true}) - eq(old_win, meths.get_current_win()) - eq(other_buf, meths.get_current_buf()) - expect('bar') - eq(2, #meths.list_wins()) + eq(same_buf_float, eval('g:win_leave')) + eq(old_win, eval('g:win_enter')) + eq(old_win, curwin().id) end) -- TODO: this case is too hard to deal with pending('if called from floating window with another buffer', function() - meths.set_current_win(other_buf_win) + meths.set_current_win(other_buf_float) meths.buf_delete(old_buf, {force = true}) end) end) - describe('creates a new buffer when there is only one listed buffer', function() - local same_buf_win, unlisted_buf, unlisted_buf_win + describe('creates an empty buffer when there is only one listed buffer', function() + local same_buf_float, unlisted_buf_float before_each(function() - same_buf_win = meths.open_win(old_buf, false, float_opts) - unlisted_buf = meths.create_buf(true, false) - unlisted_buf_win = meths.open_win(unlisted_buf, true, float_opts) - insert('bar') + same_buf_float = meths.open_win(old_buf, false, float_opts).id + local unlisted_buf = meths.create_buf(true, false).id + unlisted_buf_float = meths.open_win(unlisted_buf, true, float_opts).id + insert('unlisted') command('set nobuflisted') meths.set_current_win(old_win) end) - it('if called from non-floating window', function() - meths.buf_delete(old_buf, {force = true}) - eq(old_win, meths.get_current_win()) + after_each(function() expect('') eq(2, #meths.list_wins()) end) + it('if called from non-floating window', function() + meths.buf_delete(old_buf, {force = true}) + eq(old_win, curwin().id) + end) it('if called from floating window with the same buffer', function() - meths.set_current_win(same_buf_win) + meths.set_current_win(same_buf_float) + command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()') + command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()') meths.buf_delete(old_buf, {force = true}) - eq(old_win, meths.get_current_win()) - expect('') - eq(2, #meths.list_wins()) + eq(same_buf_float, eval('g:win_leave')) + eq(old_win, eval('g:win_enter')) + eq(old_win, curwin().id) end) -- TODO: this case is too hard to deal with pending('if called from floating window with an unlisted buffer', function() - meths.set_current_win(unlisted_buf_win) + meths.set_current_win(unlisted_buf_float) + meths.buf_delete(old_buf, {force = true}) + end) + end) + end) + describe('with splits, deleting the last listed buffer creates an empty buffer', function() + describe('when a non-floating window has an unlisted buffer', function() + local same_buf_float + before_each(function() + command('botright vnew') + insert('unlisted') + command('set nobuflisted') + meths.set_current_win(old_win) + same_buf_float = meths.open_win(old_buf, false, float_opts).id + end) + after_each(function() + expect('') + eq(2, #meths.list_wins()) + end) + it('if called from non-floating window with the deleted buffer', function() + meths.buf_delete(old_buf, {force = true}) + eq(old_win, curwin().id) + end) + it('if called from floating window with the deleted buffer', function() + meths.set_current_win(same_buf_float) meths.buf_delete(old_buf, {force = true}) + eq(same_buf_float, curwin().id) end) end) end) end) - describe('with multiple tabpages', function() - local old_tabpage, old_buf, old_win + describe('with mulitple tabpages but only one listed buffer,', function() + local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1} + local unlisted_buf, old_buf, old_win + before_each(function() + insert('unlisted') + command('set nobuflisted') + unlisted_buf = curbuf().id + command('tabnew') + insert('foo') + old_buf = curbuf().id + old_win = curwin().id + end) + describe('without splits, deleting the last listed buffer creates an empty buffer', function() + local same_buf_float + before_each(function() + meths.set_current_win(old_win) + same_buf_float = meths.open_win(old_buf, false, float_opts).id + end) + after_each(function() + expect('') + eq(2, #meths.list_wins()) + eq(2, #meths.list_tabpages()) + end) + it('if called from non-floating window', function() + meths.buf_delete(old_buf, {force = true}) + eq(old_win, curwin().id) + end) + it('if called from floating window with the same buffer', function() + meths.set_current_win(same_buf_float) + command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()') + command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()') + meths.buf_delete(old_buf, {force = true}) + eq(same_buf_float, eval('g:win_leave')) + eq(old_win, eval('g:win_enter')) + eq(old_win, curwin().id) + end) + end) + describe('with splits, deleting the last listed buffer creates an empty buffer', function() + local same_buf_float + before_each(function() + command('botright vsplit') + meths.set_current_buf(unlisted_buf) + meths.set_current_win(old_win) + same_buf_float = meths.open_win(old_buf, false, float_opts).id + end) + after_each(function() + expect('') + eq(3, #meths.list_wins()) + eq(2, #meths.list_tabpages()) + end) + it('if called from non-floating window with the deleted buffer', function() + meths.buf_delete(old_buf, {force = true}) + eq(old_win, curwin().id) + end) + it('if called from floating window with the deleted buffer', function() + meths.set_current_win(same_buf_float) + meths.buf_delete(old_buf, {force = true}) + eq(same_buf_float, curwin().id) + end) + end) + end) + + describe('with multiple tabpages and multiple listed buffers,', function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1} + local old_tabpage, old_buf, old_win before_each(function() - old_tabpage = meths.get_current_tabpage() + old_tabpage = curtab().id insert('oldtab') command('tabnew') - old_buf = meths.get_current_buf() - old_win = meths.get_current_win() + old_buf = curbuf().id + old_win = curwin().id end) describe('closing the last non-floating window', function() describe('closes the tabpage when all floating windows are closeable', function() + local same_buf_float before_each(function() - meths.open_win(old_buf, true, float_opts) + same_buf_float = meths.open_win(old_buf, false, float_opts).id end) - it('if called from non-floating window', function() - meths.set_current_win(old_win) - meths.win_close(old_win, false) - eq(old_tabpage, meths.get_current_tabpage()) + after_each(function() + eq(old_tabpage, curtab().id) expect('oldtab') eq(1, #meths.list_tabpages()) end) + it('if called from non-floating window', function() + meths.win_close(old_win, false) + end) it('if called from floating window', function() + meths.set_current_win(same_buf_float) meths.win_close(old_win, false) - eq(old_tabpage, meths.get_current_tabpage()) - expect('oldtab') - eq(1, #meths.list_tabpages()) end) end) describe('gives E5601 when there are non-closeable floating windows', function() + local other_buf_float before_each(function() command('set nohidden') - local other_buf = meths.create_buf(true, false) - meths.open_win(other_buf, true, float_opts) + local other_buf = meths.create_buf(true, false).id + other_buf_float = meths.open_win(other_buf, true, float_opts).id insert('foo') + meths.set_current_win(old_win) end) it('if called from non-floating window', function() - meths.set_current_win(old_win) eq('Vim:E5601: Cannot close window, only floating window would remain', pcall_err(meths.win_close, old_win, false)) end) it('if called from floating window', function() + meths.set_current_win(other_buf_float) eq('Vim:E5601: Cannot close window, only floating window would remain', pcall_err(meths.win_close, old_win, false)) end) @@ -572,29 +671,28 @@ describe('float window', function() end) describe("deleting the last non-floating window's buffer", function() describe('closes the tabpage when all floating windows are closeable', function() - local same_buf_win, other_buf, other_buf_win + local same_buf_float, other_buf, other_buf_float before_each(function() - same_buf_win = meths.open_win(old_buf, false, float_opts) - other_buf = meths.create_buf(true, false) - other_buf_win = meths.open_win(other_buf, true, float_opts) + same_buf_float = meths.open_win(old_buf, false, float_opts).id + other_buf = meths.create_buf(true, false).id + other_buf_float = meths.open_win(other_buf, true, float_opts).id meths.set_current_win(old_win) end) - it('if called from non-floating window', function() - meths.buf_delete(old_buf, {force = false}) - eq(old_tabpage, meths.get_current_tabpage()) + after_each(function() + eq(old_tabpage, curtab().id) expect('oldtab') eq(1, #meths.list_tabpages()) end) + it('if called from non-floating window', function() + meths.buf_delete(old_buf, {force = false}) + end) it('if called from floating window with the same buffer', function() - meths.set_current_win(same_buf_win) + meths.set_current_win(same_buf_float) meths.buf_delete(old_buf, {force = false}) - eq(old_tabpage, meths.get_current_tabpage()) - expect('oldtab') - eq(1, #meths.list_tabpages()) end) -- TODO: this case is too hard to deal with pending('if called from floating window with another buffer', function() - meths.set_current_win(other_buf_win) + meths.set_current_win(other_buf_float) meths.buf_delete(old_buf, {force = false}) end) end) diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 64f0ba3419..559738ddab 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -1081,6 +1081,46 @@ describe('CursorLine and CursorLineNr highlights', function() ]]) end) + it('is updated if cursor is moved up from timer vim-patch:8.2.4591', function() + local screen = Screen.new(50, 8) + screen:set_default_attr_ids({ + [1] = {background = Screen.colors.Gray90}, -- CursorLine + [2] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText + }) + screen:attach() + exec([[ + call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd']) + set cursorline + call cursor(4, 1) + + func Func(timer) + call cursor(2, 1) + endfunc + + call timer_start(300, 'Func') + ]]) + screen:expect({grid = [[ + aaaaa | + bbbbb | + ccccc | + {1:^ddddd }| + {2:~ }| + {2:~ }| + {2:~ }| + | + ]], timeout = 100}) + screen:expect({grid = [[ + aaaaa | + {1:^bbbbb }| + ccccc | + ddddd | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]}) + end) + it('with split windows in diff mode', function() local screen = Screen.new(50,12) screen:set_default_attr_ids({ diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 7000505909..f5ae228b1e 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -3,6 +3,7 @@ local clear, feed_command = helpers.clear, helpers.feed_command local feed, next_msg, eq = helpers.feed, helpers.next_msg, helpers.eq local command = helpers.command local expect = helpers.expect +local curbuf_contents = helpers.curbuf_contents local meths = helpers.meths local exec_lua = helpers.exec_lua local write_file = helpers.write_file @@ -159,6 +160,50 @@ describe('input split utf sequences', function() end) end) +describe('input pairs', function() + describe('<tab> / <c-i>', function() + it('ok', function() + feed('i<tab><c-i><esc>') + eq('\t\t', curbuf_contents()) + end) + + it('can be mapped', function() + command('inoremap <tab> TAB!') + command('inoremap <c-i> CTRL-I!') + feed('i<tab><c-i><esc>') + eq('TAB!CTRL-I!', curbuf_contents()) + end) + end) + + describe('<cr> / <c-m>', function() + it('ok', function() + feed('iunos<c-m>dos<cr>tres<esc>') + eq('unos\ndos\ntres', curbuf_contents()) + end) + + it('can be mapped', function() + command('inoremap <c-m> SNIPPET!') + command('inoremap <cr> , and then<cr>') + feed('iunos<c-m>dos<cr>tres<esc>') + eq('unosSNIPPET!dos, and then\ntres', curbuf_contents()) + end) + end) + + describe('<esc> / <c-[>', function() + it('ok', function() + feed('2adouble<c-[>asingle<esc>') + eq('doubledoublesingle', curbuf_contents()) + end) + + it('can be mapped', function() + command('inoremap <c-[> HALLOJ!') + command('inoremap <esc> ,<esc>') + feed('2adubbel<c-[>upp<esc>') + eq('dubbelHALLOJ!upp,dubbelHALLOJ!upp,', curbuf_contents()) + end) + end) +end) + describe('input non-printable chars', function() after_each(function() os.remove('Xtest-overwrite') |