diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-04-30 14:42:13 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-04-30 14:42:13 -0400 |
commit | 3dc8cdc1504edfd1ab44d9151954f859ab9befe2 (patch) | |
tree | 6c419ff5ea4157e6dd825ed5c7778a5c1a7c7cac /test | |
parent | cd3461b0047a7327d08ffd30b8d30fd6b92da399 (diff) | |
parent | 37f1ee0084e94792a16e473c049934a58a3c53d3 (diff) | |
download | rneovim-3dc8cdc1504edfd1ab44d9151954f859ab9befe2.tar.gz rneovim-3dc8cdc1504edfd1ab44d9151954f859ab9befe2.tar.bz2 rneovim-3dc8cdc1504edfd1ab44d9151954f859ab9befe2.zip |
Merge pull request #4676 from ZyX-I/fix-hist_char2type-crash
ex_getln: Do not crash with :append/:insert/:change
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/ex_cmds/append_spec.lua | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/functional/ex_cmds/append_spec.lua b/test/functional/ex_cmds/append_spec.lua new file mode 100644 index 0000000000..2d5ab8e8c8 --- /dev/null +++ b/test/functional/ex_cmds/append_spec.lua @@ -0,0 +1,54 @@ +local helpers = require('test.functional.helpers') + +local eq = helpers.eq +local feed = helpers.feed +local clear = helpers.clear +local funcs = helpers.funcs +local command = helpers.command +local curbufmeths = helpers.curbufmeths + +before_each(function() + clear() + curbufmeths.set_lines(0, 1, true, { 'foo', 'bar', 'baz' }) +end) + +local buffer_contents = function() + return curbufmeths.get_lines(0, -1, false) +end + +local cmdtest = function(cmd, prep, ret1) + describe(':' .. cmd, function() + it(cmd .. 's' .. prep .. ' the current line by default', function() + command(cmd .. '\nabc\ndef\n') + eq(ret1, buffer_contents()) + end) + -- Used to crash because this invokes history processing which uses + -- hist_char2type which after fdb68e35e4c729c7ed097d8ade1da29e5b3f4b31 + -- crashed. + it(cmd .. 's' .. prep .. ' the current line by default when feeding', + function() + feed(':' .. cmd .. '\nabc\ndef\n.\n') + eq(ret1, buffer_contents()) + end) + -- This used to crash since that commit as well. + it('opens empty cmdline window', function() + local hisline = '" Some comment to be stored in history' + feed(':' .. hisline .. '<CR>') + feed(':' .. cmd .. '<CR>abc<CR>def<C-f>') + eq({ 'def' }, buffer_contents()) + eq(hisline, funcs.histget(':', -2)) + eq(cmd, funcs.histget(':')) + -- Test that command-line window was launched + eq('nofile', curbufmeths.get_option('buftype')) + eq('n', funcs.mode(1)) + feed('<CR>') + eq('c', funcs.mode(1)) + feed('.<CR>') + eq('n', funcs.mode(1)) + eq(ret1, buffer_contents()) + end) + end) +end +cmdtest('insert', ' before', { 'abc', 'def', 'foo', 'bar', 'baz' }) +cmdtest('append', ' after', { 'foo', 'abc', 'def', 'bar', 'baz' }) +cmdtest('change', '', { 'abc', 'def', 'bar', 'baz' }) |