diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/ex_cmds/map_spec.lua | 22 | ||||
-rw-r--r-- | test/functional/fixtures/CMakeLists.txt | 2 | ||||
-rw-r--r-- | test/functional/lua/vim_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/vimscript/screenchar_spec.lua | 69 |
4 files changed, 91 insertions, 6 deletions
diff --git a/test/functional/ex_cmds/map_spec.lua b/test/functional/ex_cmds/map_spec.lua index eae36b9ae9..c6bdd017bd 100644 --- a/test/functional/ex_cmds/map_spec.lua +++ b/test/functional/ex_cmds/map_spec.lua @@ -86,7 +86,7 @@ n asdf1 qwert end) end) -describe(':*map cursor and redrawing', function() +describe('Screen', function() local screen before_each(function() clear() @@ -149,6 +149,18 @@ describe(':*map cursor and redrawing', function() ]]) end) + it('cursor position does not move after empty-string :cmap <expr> #19046', function() + command([[cnoremap <expr> <F2> '']]) + feed(':<F2>') + screen:expect([[ + | + ~ | + ~ | + ~ | + :^ | + ]]) + end) + it('cursor is restored after :map <expr> which redraws statusline vim-patch:8.1.2336', function() exec([[ call setline(1, ['one', 'two', 'three']) @@ -157,12 +169,12 @@ describe(':*map cursor and redrawing', function() hi! link StatusLine ErrorMsg noremap <expr> <C-B> Func() func Func() - let g:on = !get(g:, 'on', 0) - redraws - return '' + let g:on = !get(g:, 'on', 0) + redraws + return '' endfunc func Status() - return get(g:, 'on', 0) ? '[on]' : '' + return get(g:, 'on', 0) ? '[on]' : '' endfunc set stl=%{Status()} ]]) diff --git a/test/functional/fixtures/CMakeLists.txt b/test/functional/fixtures/CMakeLists.txt index 270540de2e..6010fcaf1e 100644 --- a/test/functional/fixtures/CMakeLists.txt +++ b/test/functional/fixtures/CMakeLists.txt @@ -4,7 +4,7 @@ target_link_libraries(tty-test ${LIBUV_LIBRARIES}) add_executable(shell-test EXCLUDE_FROM_ALL shell-test.c) add_executable(printargs-test EXCLUDE_FROM_ALL printargs-test.c) add_executable(printenv-test EXCLUDE_FROM_ALL printenv-test.c) -if(WIN32) +if(MINGW) set_target_properties(printenv-test PROPERTIES LINK_FLAGS -municode) endif() diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 44e65afc78..646c5ac8ca 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -1400,6 +1400,8 @@ describe('lua stdlib', function() pcall_err(exec_lua, 'return vim.bo.nosuchopt')) matches("Expected lua string$", pcall_err(exec_lua, 'return vim.bo[0][0].autoread')) + matches("Invalid buffer id: %-1$", + pcall_err(exec_lua, 'return vim.bo[-1].filetype')) end) it('vim.wo', function() @@ -1419,6 +1421,8 @@ describe('lua stdlib', function() pcall_err(exec_lua, 'return vim.wo.notanopt')) matches("Expected lua string$", pcall_err(exec_lua, 'return vim.wo[0][0].list')) + matches("Invalid window id: %-1$", + pcall_err(exec_lua, 'return vim.wo[-1].list')) eq(2, funcs.luaeval "vim.wo[1000].cole") exec_lua [[ vim.wo[1000].cole = 0 diff --git a/test/functional/vimscript/screenchar_spec.lua b/test/functional/vimscript/screenchar_spec.lua new file mode 100644 index 0000000000..767e3c57ef --- /dev/null +++ b/test/functional/vimscript/screenchar_spec.lua @@ -0,0 +1,69 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq +local command, meths, funcs = helpers.command, helpers.meths, helpers.funcs +local tbl_deep_extend = helpers.tbl_deep_extend + +-- Set up two overlapping floating windows +local setup_floating_windows = function() + local base_opts = { + relative = 'editor', + height = 1, + width = 2, + anchor = 'NW', + style = 'minimal', + border = 'none', + } + + local bufnr_1 = meths.create_buf(false, true) + meths.buf_set_lines(bufnr_1, 0, -1, true, { 'aa' }) + local opts_1 = tbl_deep_extend('force', { row = 0, col = 0, zindex = 11 }, base_opts) + meths.open_win(bufnr_1, false, opts_1) + + local bufnr_2 = meths.create_buf(false, true) + meths.buf_set_lines(bufnr_2, 0, -1, true, { 'bb' }) + local opts_2 = tbl_deep_extend('force', { row = 0, col = 1, zindex = 10 }, base_opts) + meths.open_win(bufnr_2, false, opts_2) + + command('redraw') +end + +describe('screenchar() and family respect floating windows', function() + before_each(function() + clear() + -- These commands result into visible text `aabc`. + -- `aab` - from floating windows, `c` - from text in regular window. + meths.buf_set_lines(0, 0, -1, true, { 'cccc' }) + setup_floating_windows() + end) + + it('screenattr()', function() + local attr_1 = funcs.screenattr(1, 1) + local attr_2 = funcs.screenattr(1, 2) + local attr_3 = funcs.screenattr(1, 3) + local attr_4 = funcs.screenattr(1, 4) + eq(attr_1, attr_2) + eq(attr_1, attr_3) + neq(attr_1, attr_4) + end) + + it('screenchar()', function() + eq(97, funcs.screenchar(1, 1)) + eq(97, funcs.screenchar(1, 2)) + eq(98, funcs.screenchar(1, 3)) + eq(99, funcs.screenchar(1, 4)) + end) + + it('screenchars()', function() + eq({ 97 }, funcs.screenchars(1, 1)) + eq({ 97 }, funcs.screenchars(1, 2)) + eq({ 98 }, funcs.screenchars(1, 3)) + eq({ 99 }, funcs.screenchars(1, 4)) + end) + + it('screenstring()', function() + eq('a', funcs.screenstring(1, 1)) + eq('a', funcs.screenstring(1, 2)) + eq('b', funcs.screenstring(1, 3)) + eq('c', funcs.screenstring(1, 4)) + end) +end) |