diff options
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/api/extmark_spec.lua | 9 | ||||
-rw-r--r-- | test/functional/api/highlight_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/core/job_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/legacy/display_spec.lua | 31 | ||||
-rw-r--r-- | test/functional/legacy/visual_mode_spec.lua | 42 | ||||
-rw-r--r-- | test/functional/lua/buffer_updates_spec.lua | 202 | ||||
-rw-r--r-- | test/functional/lua/treesitter_spec.lua | 38 | ||||
-rw-r--r-- | test/functional/lua/vim_spec.lua | 70 | ||||
-rw-r--r-- | test/functional/normal/meta_key_spec.lua | 22 | ||||
-rw-r--r-- | test/functional/ui/cmdline_spec.lua | 32 | ||||
-rw-r--r-- | test/functional/ui/cursor_spec.lua | 17 | ||||
-rw-r--r-- | test/functional/ui/fold_spec.lua | 46 | ||||
-rw-r--r-- | test/functional/ui/inccommand_spec.lua | 20 | ||||
-rw-r--r-- | test/functional/ui/messages_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/visual/meta_key_spec.lua | 22 |
15 files changed, 519 insertions, 47 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index a2a188d036..ab913ba4a4 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -100,6 +100,15 @@ describe('API/extmarks', function() ns2 = request('nvim_create_namespace', "my-fancy-plugin2") end) + it("can end extranges past final newline using end_col = 0", function() + set_extmark(ns, marks[1], 0, 0, { + end_col = 0, + end_line = 1 + }) + eq("end_col value outside range", + pcall_err(set_extmark, ns, marks[2], 0, 0, { end_col = 1, end_line = 1 })) + end) + it('adds, updates and deletes marks', function() local rv = set_extmark(ns, marks[1], positions[1][1], positions[1][2]) eq(marks[1], rv) diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua index a9d4c72d31..daf20c006c 100644 --- a/test/functional/api/highlight_spec.lua +++ b/test/functional/api/highlight_spec.lua @@ -7,6 +7,7 @@ local meths = helpers.meths local funcs = helpers.funcs local pcall_err = helpers.pcall_err local ok = helpers.ok +local assert_alive = helpers.assert_alive describe('API: highlight',function() local expected_rgb = { @@ -145,4 +146,15 @@ describe('API: highlight',function() eq({foreground=tonumber("0x888888"), background=tonumber("0x888888")}, meths.get_hl_by_name("Shrubbery", true)) end) + + it("nvim_buf_add_highlight to other buffer doesn't crash if undo is disabled #12873", function() + command('vsplit file') + local err, _ = pcall(meths.buf_set_option, 1, 'undofile', false) + eq(true, err) + err, _ = pcall(meths.buf_set_option, 1, 'undolevels', -1) + eq(true, err) + err, _ = pcall(meths.buf_add_highlight, 1, -1, 'Question', 0, 0, -1) + eq(true, err) + assert_alive() + end) end) diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 57e6f4fd63..1155f12ffc 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -93,6 +93,7 @@ describe('jobs', function() {'notification', 'stdout', {0, {'hello world %VAR%', ''}}} }) else + nvim('command', "set shell=/bin/sh") nvim('command', [[call jobstart('echo $TOTO $VAR', g:job_opts)]]) expect_msg_seq({ {'notification', 'stdout', {0, {'hello world', ''}}} diff --git a/test/functional/legacy/display_spec.lua b/test/functional/legacy/display_spec.lua new file mode 100644 index 0000000000..aafcda67dc --- /dev/null +++ b/test/functional/legacy/display_spec.lua @@ -0,0 +1,31 @@ +local helpers = require('test.functional.helpers')(after_each) + +local Screen = require('test.functional.ui.screen') +local clear = helpers.clear +local wait = helpers.wait +local feed = helpers.feed +local feed_command = helpers.feed_command + +describe('display', function() + local screen + + it('scroll when modified at topline', function() + clear() + screen = Screen.new(20, 4) + screen:attach() + screen:set_default_attr_ids({ + [1] = {bold = true}, + }) + + feed_command([[call setline(1, repeat('a', 21))]]) + wait() + feed('O') + screen:expect([[ + ^ | + aaaaaaaaaaaaaaaaaaaa| + a | + {1:-- INSERT --} | + ]]) + end) +end) + diff --git a/test/functional/legacy/visual_mode_spec.lua b/test/functional/legacy/visual_mode_spec.lua new file mode 100644 index 0000000000..c8e83ed649 --- /dev/null +++ b/test/functional/legacy/visual_mode_spec.lua @@ -0,0 +1,42 @@ +-- Test visual line mode selection redraw after scrolling + +local helpers = require('test.functional.helpers')(after_each) + +local Screen = require('test.functional.ui.screen') +local call = helpers.call +local clear = helpers.clear +local feed = helpers.feed +local feed_command = helpers.feed_command +local funcs = helpers.funcs +local meths = helpers.meths +local eq = helpers.eq + +describe('visual line mode', function() + local screen + + it('redraws properly after scrolling with matchparen loaded and scrolloff=1', function() + clear{args={'-u', 'NORC'}} + screen = Screen.new(30, 7) + screen:attach() + screen:set_default_attr_ids({ + [1] = {bold = true}, + [2] = {background = Screen.colors.LightGrey}, + }) + + eq(1, meths.get_var('loaded_matchparen')) + feed_command('set scrolloff=1') + funcs.setline(1, {'a', 'b', 'c', 'd', 'e', '', '{', '}', '{', 'f', 'g', '}'}) + call('cursor', 5, 1) + + feed('V<c-d><c-d>') + screen:expect([[ + {2:{} | + {2:}} | + {2:{} | + {2:f} | + ^g | + } | + {1:-- VISUAL LINE --} | + ]]) + end) +end) diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index 5be47070a7..fa31880782 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -5,6 +5,7 @@ local inspect = require'vim.inspect' local command = helpers.command local meths = helpers.meths +local funcs = helpers.funcs local clear = helpers.clear local eq = helpers.eq local fail = helpers.fail @@ -244,6 +245,31 @@ describe('lua buffer event callbacks: on_lines', function() helpers.assert_alive() end) + it('#12718 lnume', function() + meths.buf_set_lines(0, 0, -1, true, {'1', '2', '3'}) + exec_lua([[ + vim.api.nvim_buf_attach(0, false, { + on_lines = function(...) + vim.api.nvim_set_var('linesev', { ... }) + end, + }) + ]]) + feed('1G0') + feed('y<C-v>2j') + feed('G0') + feed('p') + -- Is the last arg old_byte_size correct? Doesn't matter for this PR + eq(meths.get_var('linesev'), { "lines", 1, 4, 2, 3, 5, 4 }) + + feed('2G0') + feed('p') + eq(meths.get_var('linesev'), { "lines", 1, 5, 1, 4, 4, 8 }) + + feed('1G0') + feed('P') + eq(meths.get_var('linesev'), { "lines", 1, 6, 0, 3, 3, 9 }) + + end) end) describe('lua: nvim_buf_attach on_bytes', function() @@ -256,9 +282,9 @@ describe('lua: nvim_buf_attach on_bytes', function() -- assert the wrong thing), but masks errors with unflushed lines (as -- nvim_buf_get_offset forces a flush of the memline). To be safe run the -- test both ways. - local function setup_eventcheck(verify) - meths.buf_set_lines(0, 0, -1, true, origlines) - local shadow = deepcopy(origlines) + local function setup_eventcheck(verify, start_txt) + meths.buf_set_lines(0, 0, -1, true, start_txt) + local shadow = deepcopy(start_txt) local shadowbytes = table.concat(shadow, '\n') .. '\n' -- TODO: while we are brewing the real strong coffe, -- verify should check buf_get_offset after every check_events @@ -273,7 +299,7 @@ describe('lua: nvim_buf_attach on_bytes', function() local events = exec_lua("return get_events(...)" ) if not pcall(eq, expected, events) then - local msg = 'unexpected byte updates received.\n\nBABBLA MER \n\n' + local msg = 'unexpected byte updates received.\n\n' msg = msg .. 'received events:\n' for _, e in ipairs(events) do @@ -286,26 +312,36 @@ describe('lua: nvim_buf_attach on_bytes', function() fail(msg) end - if verify then - for _, event in ipairs(events) do - if event[1] == verify_name and event[2] == "bytes" then - local _, _, _, _, _, _, start_byte, _, _, old_byte, _, _, new_byte = unpack(event) - local before = string.sub(shadowbytes, 1, start_byte) - -- no text in the tests will contain 0xff bytes (invalid UTF-8) - -- so we can use it as marker for unknown bytes - local unknown = string.rep('\255', new_byte) - local after = string.sub(shadowbytes, start_byte + old_byte + 1) - shadowbytes = before .. unknown .. after + if not verify then + return + end + + for _, event in ipairs(events) do + for _, elem in ipairs(event) do + if type(elem) == "number" and elem < 0 then + fail(string.format("Received event has negative values")) end end - local text = meths.buf_get_lines(0, 0, -1, true) - local bytes = table.concat(text, '\n') .. '\n' - eq(string.len(bytes), string.len(shadowbytes), shadowbytes) - for i = 1, string.len(shadowbytes) do - local shadowbyte = string.sub(shadowbytes, i, i) - if shadowbyte ~= '\255' then - eq(string.sub(bytes, i, i), shadowbyte, i) - end + + if event[1] == verify_name and event[2] == "bytes" then + local _, _, _, _, _, _, start_byte, _, _, old_byte, _, _, new_byte = unpack(event) + local before = string.sub(shadowbytes, 1, start_byte) + -- no text in the tests will contain 0xff bytes (invalid UTF-8) + -- so we can use it as marker for unknown bytes + local unknown = string.rep('\255', new_byte) + local after = string.sub(shadowbytes, start_byte + old_byte + 1) + shadowbytes = before .. unknown .. after + end + end + + local text = meths.buf_get_lines(0, 0, -1, true) + local bytes = table.concat(text, '\n') .. '\n' + + eq(string.len(bytes), string.len(shadowbytes), '\non_bytes: total bytecount of buffer is wrong') + for i = 1, string.len(shadowbytes) do + local shadowbyte = string.sub(shadowbytes, i, i) + if shadowbyte ~= '\255' then + eq(string.sub(bytes, i, i), shadowbyte, i) end end end @@ -316,7 +352,7 @@ describe('lua: nvim_buf_attach on_bytes', function() -- Yes, we can do both local function do_both(verify) it('single and multiple join', function() - local check_events = setup_eventcheck(verify) + local check_events = setup_eventcheck(verify, origlines) feed 'ggJ' check_events { {'test1', 'bytes', 1, 3, 0, 15, 15, 1, 0, 1, 0, 1, 1}; @@ -330,7 +366,7 @@ describe('lua: nvim_buf_attach on_bytes', function() end) it('opening lines', function() - local check_events = setup_eventcheck(verify) + local check_events = setup_eventcheck(verify, origlines) -- meths.buf_set_option(0, 'autoindent', true) feed 'Go' check_events { @@ -343,7 +379,7 @@ describe('lua: nvim_buf_attach on_bytes', function() end) it('opening lines with autoindent', function() - local check_events = setup_eventcheck(verify) + local check_events = setup_eventcheck(verify, origlines) meths.buf_set_option(0, 'autoindent', true) feed 'Go' check_events { @@ -355,6 +391,122 @@ describe('lua: nvim_buf_attach on_bytes', function() { "test1", "bytes", 1, 5, 7, 4, 118, 0, 0, 0, 1, 4, 5 }; } end) + + it('setline(num, line)', function() + local check_events = setup_eventcheck(verify, origlines) + funcs.setline(2, "babla") + check_events { + { "test1", "bytes", 1, 3, 1, 0, 16, 0, 15, 15, 0, 5, 5 }; + } + + funcs.setline(2, {"foo", "bar"}) + check_events { + { "test1", "bytes", 1, 4, 1, 0, 16, 0, 5, 5, 0, 3, 3 }; + { "test1", "bytes", 1, 5, 2, 0, 20, 0, 15, 15, 0, 3, 3 }; + } + + local buf_len = meths.buf_line_count(0) + funcs.setline(buf_len + 1, "baz") + check_events { + { "test1", "bytes", 1, 6, 7, 0, 90, 0, 0, 0, 1, 0, 4 }; + } + end) + + it('continuing comments with fo=or', function() + local check_events = setup_eventcheck(verify, {'// Comment'}) + meths.buf_set_option(0, 'formatoptions', 'ro') + meths.buf_set_option(0, 'filetype', 'c') + feed 'A<CR>' + check_events { + { "test1", "bytes", 1, 4, 0, 10, 10, 0, 0, 0, 1, 3, 4 }; + } + + feed '<ESC>' + check_events { + { "test1", "bytes", 1, 4, 1, 2, 13, 0, 1, 1, 0, 0, 0 }; + } + + feed 'ggo' -- goto first line to continue testing + check_events { + { "test1", "bytes", 1, 6, 1, 0, 11, 0, 0, 0, 1, 0, 4 }; + } + + feed '<CR>' + check_events { + { "test1", "bytes", 1, 6, 2, 2, 16, 0, 1, 1, 0, 0, 0 }; + { "test1", "bytes", 1, 7, 1, 3, 14, 0, 0, 0, 1, 3, 4 }; + } + end) + + it('editing empty buffers', function() + local check_events = setup_eventcheck(verify, {}) + + feed 'ia' + check_events { + { "test1", "bytes", 1, 3, 0, 0, 0, 0, 0, 0, 0, 1, 1 }; + } + end) + + it("changing lines", function() + local check_events = setup_eventcheck(verify, origlines) + + feed "cc" + check_events { + { "test1", "bytes", 1, 4, 0, 0, 0, 0, 15, 15, 0, 0, 0 }; + } + + feed "<ESC>" + check_events {} + + feed "c3j" + check_events { + { "test1", "bytes", 1, 4, 1, 0, 1, 3, 0, 48, 0, 0, 0 }; + } + end) + + it("visual charwise paste", function() + local check_events = setup_eventcheck(verify, {'1234567890'}) + funcs.setreg('a', '___') + + feed '1G1|vll' + check_events {} + + feed '"ap' + check_events { + { "test1", "bytes", 1, 3, 0, 0, 0, 0, 3, 3, 0, 0, 0 }; + { "test1", "bytes", 1, 5, 0, 0, 0, 0, 0, 0, 0, 3, 3 }; + } + end) + + it('blockwise paste', function() + local check_events = setup_eventcheck(verify, {'1', '2', '3'}) + feed('1G0') + feed('y<C-v>2j') + feed('G0') + feed('p') + check_events { + { "test1", "bytes", 1, 3, 2, 1, 5, 0, 0, 0, 0, 1, 1 }; + { "test1", "bytes", 1, 3, 3, 0, 7, 0, 0, 0, 0, 3, 3 }; + { "test1", "bytes", 1, 3, 4, 0, 10, 0, 0, 0, 0, 3, 3 }; + } + + feed('2G0') + feed('p') + check_events { + { "test1", "bytes", 1, 4, 1, 1, 3, 0, 0, 0, 0, 1, 1 }; + { "test1", "bytes", 1, 4, 2, 1, 6, 0, 0, 0, 0, 1, 1 }; + { "test1", "bytes", 1, 4, 3, 1, 10, 0, 0, 0, 0, 1, 1 }; + } + + feed('1G0') + feed('P') + check_events { + { "test1", "bytes", 1, 5, 0, 0, 0, 0, 0, 0, 0, 1, 1 }; + { "test1", "bytes", 1, 5, 1, 0, 3, 0, 0, 0, 0, 1, 1 }; + { "test1", "bytes", 1, 5, 2, 0, 7, 0, 0, 0, 0, 1, 1 }; + } + + end) end describe('(with verify) handles', function() diff --git a/test/functional/lua/treesitter_spec.lua b/test/functional/lua/treesitter_spec.lua index 2c9107a65a..74ae6cde2b 100644 --- a/test/functional/lua/treesitter_spec.lua +++ b/test/functional/lua/treesitter_spec.lua @@ -446,10 +446,7 @@ static int nlua_schedule(lua_State *const lstate) ]]} feed("5Goc<esc>dd") - if true == true then - pending('reenable this check in luahl PR') - return - end + screen:expect{grid=[[ {2:/// Schedule Lua callback on main loop's event queue} | {3:static} {3:int} {11:nlua_schedule}({3:lua_State} *{3:const} lstate) | @@ -480,7 +477,7 @@ static int nlua_schedule(lua_State *const lstate) || {6:lstate} != {6:lstate}) { | {11:lua_pushliteral}(lstate, {5:"vim.schedule: expected function"}); | {4:return} {11:lua_error}(lstate); | - *^/ | + {8:*^/} | } | | {7:LuaRef} cb = {11:nlua_ref}(lstate, {5:1}); | @@ -663,4 +660,35 @@ static int nlua_schedule(lua_State *const lstate) { 10, 5, 10, 20 }, { 14, 9, 14, 27 } }, res) end) + + it("allows to create string parsers", function() + local ret = exec_lua [[ + local parser = vim.treesitter.get_string_parser("int foo = 42;", "c") + return { parser:parse():root():range() } + ]] + + eq({ 0, 0, 0, 13 }, ret) + end) + + it("allows to run queries with string parsers", function() + local txt = [[ + int foo = 42; + int bar = 13; + ]] + + local ret = exec_lua([[ + local str = ... + local parser = vim.treesitter.get_string_parser(str, "c") + + local nodes = {} + local query = vim.treesitter.parse_query("c", '((identifier) @id (eq? @id "foo"))') + + for _, node in query:iter_captures(parser:parse():root(), str, 0, 2) do + table.insert(nodes, { node:range() }) + end + + return nodes]], txt) + + eq({ {0, 10, 0, 13} }, ret) + end) end) diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index a9e8ca9686..63e48a18ca 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -1214,6 +1214,23 @@ describe('lua stdlib', function() ]]) end) + it('should not process non-fast events when commanded', function() + eq({wait_result = false}, exec_lua[[ + start_time = get_time() + + vim.g.timer_result = false + timer = vim.loop.new_timer() + timer:start(100, 0, vim.schedule_wrap(function() + vim.g.timer_result = true + end)) + + wait_result = vim.wait(300, function() return vim.g.timer_result end, nil, true) + + return { + wait_result = wait_result, + } + ]]) + end) it('should work with vim.defer_fn', function() eq({time = true, wait_result = true}, exec_lua[[ start_time = get_time() @@ -1228,22 +1245,38 @@ describe('lua stdlib', function() ]]) end) - it('should require functions to be passed', function() + it('should not crash when callback errors', function() local pcall_result = exec_lua [[ - return {pcall(function() vim.wait(1000, 13) end)} + return {pcall(function() vim.wait(1000, function() error("As Expected") end) end)} ]] eq(pcall_result[1], false) - matches('condition must be a function', pcall_result[2]) + matches('As Expected', pcall_result[2]) end) - it('should not crash when callback errors', function() + it('if callback is passed, it must be a function', function() local pcall_result = exec_lua [[ - return {pcall(function() vim.wait(1000, function() error("As Expected") end) end)} + return {pcall(function() vim.wait(1000, 13) end)} ]] eq(pcall_result[1], false) - matches('As Expected', pcall_result[2]) + matches('if passed, condition must be a function', pcall_result[2]) + end) + + it('should allow waiting with no callback, explicit', function() + eq(true, exec_lua [[ + local start_time = vim.loop.hrtime() + vim.wait(50, nil) + return vim.loop.hrtime() - start_time > 25000 + ]]) + end) + + it('should allow waiting with no callback, implicit', function() + eq(true, exec_lua [[ + local start_time = vim.loop.hrtime() + vim.wait(50) + return vim.loop.hrtime() - start_time > 25000 + ]]) end) it('should call callbacks exactly once if they return true immediately', function() @@ -1330,4 +1363,29 @@ describe('lua stdlib', function() eq(false, pcall_result) end) end) + + describe('vim.api.nvim_buf_call', function() + it('can access buf options', function() + local buf1 = meths.get_current_buf() + local buf2 = exec_lua [[ + buf2 = vim.api.nvim_create_buf(false, true) + return buf2 + ]] + + eq(false, meths.buf_get_option(buf1, 'autoindent')) + eq(false, meths.buf_get_option(buf2, 'autoindent')) + + local val = exec_lua [[ + return vim.api.nvim_buf_call(buf2, function() + vim.cmd "set autoindent" + return vim.api.nvim_get_current_buf() + end) + ]] + + eq(false, meths.buf_get_option(buf1, 'autoindent')) + eq(true, meths.buf_get_option(buf2, 'autoindent')) + eq(buf1, meths.get_current_buf()) + eq(buf2, val) + end) + end) end) diff --git a/test/functional/normal/meta_key_spec.lua b/test/functional/normal/meta_key_spec.lua new file mode 100644 index 0000000000..9f9fad67d2 --- /dev/null +++ b/test/functional/normal/meta_key_spec.lua @@ -0,0 +1,22 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local command = helpers.command +local expect = helpers.expect + +describe('meta-keys-in-normal-mode', function() + before_each(function() + clear() + end) + + it('ALT/META', function() + -- Unmapped ALT-chords behave as Esc+c + insert('hello') + feed('0<A-x><M-x>') + expect('llo') + -- Mapped ALT-chord behaves as mapped. + command('nnoremap <M-l> Ameta-l<Esc>') + command('nnoremap <A-j> Aalt-j<Esc>') + feed('<A-j><M-l>') + expect('lloalt-jmeta-l') + end) +end) diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 21c01b3458..01f0d8a4d7 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -3,6 +3,7 @@ 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) @@ -842,3 +843,34 @@ 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/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 6c913124ac..e1a72ced05 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -286,6 +286,21 @@ describe('ui/cursor', function() eq(173, named.normal.blinkon) eq(42, named.showmatch.cell_percentage) end) + + -- If there is no setting for guicursor, it becomes the default setting. + meths.set_option('guicursor', 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor') + screen:expect(function() + for _,m in ipairs(screen._mode_info) do + if m.name ~= 'normal' then + eq('block', m.cursor_shape or 'block') + eq(0, m.blinkon or 0) + eq(0, m.blinkoff or 0) + eq(0, m.blinkwait or 0) + eq(0, m.hl_id or 0) + eq(0, m.id_lm or 0) + end + end + end) end) it("empty 'guicursor' sets cursor_shape=block in all modes", function() @@ -297,6 +312,8 @@ describe('ui/cursor', function() if m['cursor_shape'] ~= nil then eq('block', m.cursor_shape) eq(0, m.blinkon) + eq(0, m.hl_id) + eq(0, m.id_lm) end end end) diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 6ec45064da..9877f30206 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -6,6 +6,8 @@ local feed_command = helpers.feed_command local insert = helpers.insert local funcs = helpers.funcs local meths = helpers.meths +local source = helpers.source +local assert_alive = helpers.assert_alive describe("folded lines", function() local screen @@ -21,6 +23,8 @@ describe("folded lines", function() [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}, [6] = {background = Screen.colors.Yellow}, [7] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, + [8] = {foreground = Screen.colors.Brown }, + [9] = {bold = true, foreground = Screen.colors.Brown} }) end) @@ -29,7 +33,7 @@ describe("folded lines", function() feed("i<cr><esc>") feed("vkzf") screen:expect([[ - {5: ^+-- 2 lines: ·············}| + {7: }{5:^+-- 2 lines: ·············}| {1:~ }| {1:~ }| {1:~ }| @@ -49,8 +53,8 @@ describe("folded lines", function() funcs.setline(4, 'line 2') feed("j") screen:expect([[ - {7:+ }{5: 1 +-- 2 lines: ·························}| - {7:+ }{5: 0 ^+-- 2 lines: ·························}| + {7:+ }{8: 1 }{5:+-- 2 lines: ·························}| + {7:+ }{9: 0 }{5:^+-- 2 lines: ·························}| {1:~ }| {1:~ }| {1:~ }| @@ -130,8 +134,8 @@ describe("folded lines", function() ]]) feed('vkzf') - screen:expect([[ - {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}| + screen:expect{grid=[[ + {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة·················}| {1:~ }| {1:~ }| {1:~ }| @@ -139,7 +143,7 @@ describe("folded lines", function() {1:~ }| {1:~ }| | - ]]) + ]]} feed_command("set noarabicshape") screen:expect([[ @@ -155,7 +159,7 @@ describe("folded lines", function() feed_command("set number foldcolumn=2") screen:expect([[ - {7:+ }{5: 1 ^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة···········}| + {7:+ }{8: 1 }{5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة···········}| {1:~ }| {1:~ }| {1:~ }| @@ -168,7 +172,7 @@ describe("folded lines", function() -- Note: too much of the folded line gets cut off.This is a vim bug. feed_command("set rightleft") screen:expect([[ - {5:+-- 2 lines: å ······················^· 1 }{7: +}| + {5:···········ةيَّبِرَعَلا x̎͂̀̂͛͛ 语 å :senil 2 --^+}{8: 1 }{7: +}| {1: ~}| {1: ~}| {1: ~}| @@ -180,7 +184,7 @@ describe("folded lines", function() feed_command("set nonumber foldcolumn=0") screen:expect([[ - {5:+-- 2 lines: å 语 x̎͂̀̂͛͛ ال·····················^·}| + {5:·················ةيَّبِرَعَلا x̎͂̀̂͛͛ 语 å :senil 2 --^+}| {1: ~}| {1: ~}| {1: ~}| @@ -192,7 +196,7 @@ describe("folded lines", function() feed_command("set arabicshape") screen:expect([[ - {5:+-- 2 lines: å 语 x̎͂̀̂͛͛ ﺍﻟ·····················^·}| + {5:·················ةيَّبِرَعَلا x̎͂̀̂͛͛ 语 å :senil 2 --^+}| {1: ~}| {1: ~}| {1: ~}| @@ -355,4 +359,26 @@ describe("folded lines", function() | ]]} end) + + it('does not crash when foldtext is longer than columns #12988', function() + source([[ + function! MyFoldText() abort + return repeat('-', &columns + 100) + endfunction + ]]) + command('set foldtext=MyFoldText()') + feed("i<cr><esc>") + feed("vkzf") + screen:expect{grid=[[ + {5:^---------------------------------------------}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + assert_alive() + end) end) diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 74e85212c8..16c5477ee4 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -2750,6 +2750,26 @@ it(':substitute with inccommand, timer-induced :redraw #9777', function() ]]) end) +it(":substitute doesn't crash with inccommand, if undo is empty #12932", function() + local screen = Screen.new(10,5) + clear() + command('set undolevels=-1') + common_setup(screen, 'split', 'test') + feed(':%s/test') + sleep(100) + feed('/') + sleep(100) + feed('f') + screen:expect([[ + {12:f} | + {15:~ }| + {15:~ }| + {15:~ }| + :%s/test/f^ | + ]]) + assert_alive() +end) + it('long :%s/ with inccommand does not collapse cmdline', function() local screen = Screen.new(10,5) clear() diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index efc02db159..5df4a1d533 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -323,7 +323,7 @@ describe('ui/ext_messages', function() {1:~ }| {1:~ }| ]], messages={ - {content = {{"/line [1/2] W"}}, kind = "search_count"} + {content = {{"/line W [1/2]"}}, kind = "search_count"} }} feed('n') diff --git a/test/functional/visual/meta_key_spec.lua b/test/functional/visual/meta_key_spec.lua new file mode 100644 index 0000000000..11f7203da0 --- /dev/null +++ b/test/functional/visual/meta_key_spec.lua @@ -0,0 +1,22 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local command = helpers.command +local expect = helpers.expect + +describe('meta-keys-in-visual-mode', function() + before_each(function() + clear() + end) + + it('ALT/META', function() + -- Unmapped ALT-chords behave as Esc+c + insert('peaches') + feed('viw<A-x>viw<M-x>') + expect('peach') + -- Mapped ALT-chord behaves as mapped. + command('vnoremap <M-l> Ameta-l<Esc>') + command('vnoremap <A-j> Aalt-j<Esc>') + feed('viw<A-j>viw<M-l>') + expect('peachalt-jmeta-l') + end) +end) |