diff options
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r-- | test/functional/api/vim_spec.lua | 106 |
1 files changed, 80 insertions, 26 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 858463efbd..3724dbf820 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1469,6 +1469,17 @@ describe('API', function() nvim('win_set_option', win, 'number', true) eq(true, nvim('get_option_value', 'number', {win = win})) end) + + it('getting current buffer option does not adjust cursor #19381', function() + nvim('command', 'new') + local buf = nvim('get_current_buf').id + local win = nvim('get_current_win').id + insert('some text') + feed('0v$') + eq({1, 9}, nvim('win_get_cursor', win)) + nvim('get_option_value', 'filetype', {buf = buf}) + eq({1, 9}, nvim('win_get_cursor', win)) + end) end) describe('nvim_{get,set}_current_buf, nvim_list_bufs', function() @@ -3181,10 +3192,11 @@ describe('API', function() noswapfile = false, sandbox = false, silent = false, - vertical = false, split = "", tab = 0, - verbose = -1 + unsilent = false, + verbose = -1, + vertical = false, } }, meths.parse_cmd('echo foo', {})) end) @@ -3221,10 +3233,11 @@ describe('API', function() noswapfile = false, sandbox = false, silent = false, - vertical = false, split = "", tab = 0, - verbose = -1 + unsilent = false, + verbose = -1, + vertical = false, } }, meths.parse_cmd('4,6s/math.random/math.max/', {})) end) @@ -3261,10 +3274,11 @@ describe('API', function() noswapfile = false, sandbox = false, silent = false, - vertical = false, split = "", tab = 0, - verbose = -1 + unsilent = false, + verbose = -1, + vertical = false, } }, meths.parse_cmd('buffer 1', {})) end) @@ -3301,10 +3315,11 @@ describe('API', function() noswapfile = false, sandbox = false, silent = false, - vertical = false, split = "", tab = 0, - verbose = -1 + unsilent = false, + verbose = -1, + vertical = false, } }, meths.parse_cmd('put +', {})) end) @@ -3341,10 +3356,11 @@ describe('API', function() noswapfile = false, sandbox = false, silent = false, - vertical = false, split = "", tab = 0, - verbose = -1 + unsilent = false, + verbose = -1, + vertical = false, } }, meths.parse_cmd('1,3delete * 5', {})) end) @@ -3381,10 +3397,11 @@ describe('API', function() noswapfile = false, sandbox = false, silent = false, - vertical = false, split = "", tab = 0, - verbose = -1 + unsilent = false, + verbose = -1, + vertical = false, }, }, meths.parse_cmd('w!', {})) end) @@ -3421,10 +3438,11 @@ describe('API', function() noswapfile = false, sandbox = false, silent = true, - vertical = false, split = "topleft", tab = 2, - verbose = 15 + unsilent = false, + verbose = 15, + vertical = false, }, }, meths.parse_cmd('15verbose silent! aboveleft topleft tab filter /foo/ split foo.txt', {})) eq({ @@ -3443,7 +3461,7 @@ describe('API', function() nextcmd = '', mods = { browse = false, - confirm = false, + confirm = true, emsg_silent = false, filter = { pattern = "foo", @@ -3459,12 +3477,13 @@ describe('API', function() noswapfile = false, sandbox = false, silent = false, - vertical = false, - split = "", + split = "botright", tab = 0, - verbose = -1 + unsilent = true, + verbose = 0, + vertical = false, }, - }, meths.parse_cmd('filter! /foo/ split foo.txt', {})) + }, meths.parse_cmd('0verbose unsilent botright confirm filter! /foo/ split foo.txt', {})) end) it('works with user commands', function() command('command -bang -nargs=+ -range -addr=lines MyCommand echo foo') @@ -3500,10 +3519,11 @@ describe('API', function() noswapfile = false, sandbox = false, silent = false, - vertical = false, split = "", tab = 0, - verbose = -1 + unsilent = false, + verbose = -1, + vertical = false, } }, meths.parse_cmd('4,6MyCommand! test it', {})) end) @@ -3540,10 +3560,11 @@ describe('API', function() noswapfile = false, sandbox = false, silent = false, - vertical = false, split = "", tab = 0, - verbose = -1 + unsilent = false, + verbose = -1, + vertical = false, } }, meths.parse_cmd('argadd a.txt | argadd b.txt', {})) end) @@ -3581,10 +3602,11 @@ describe('API', function() noswapfile = false, sandbox = false, silent = false, - vertical = false, split = "", tab = 0, - verbose = -1 + unsilent = false, + verbose = -1, + vertical = false, } }, meths.parse_cmd('MyCommand test it', {})) end) @@ -3602,6 +3624,38 @@ describe('API', function() eq('Error while parsing command line: E464: Ambiguous use of user-defined command', pcall_err(meths.parse_cmd, 'F', {})) end) + it('does not interfere with printing line in Ex mode #19400', function() + local screen = Screen.new(60, 7) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, reverse = true}, -- MsgSeparator + }) + screen:attach() + insert([[ + foo + bar]]) + feed('gQ1') + screen:expect([[ + foo | + bar | + {0:~ }| + {0:~ }| + {1: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :1^ | + ]]) + eq('Error while parsing command line', pcall_err(meths.parse_cmd, '', {})) + feed('<CR>') + screen:expect([[ + foo | + bar | + {1: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :1 | + foo | + :^ | + ]]) + end) end) describe('nvim_cmd', function() it('works', function () @@ -3748,7 +3802,7 @@ describe('API', function() eq("foo", meths.cmd({ cmd = "Foo" }, { output = true })) end) it('errors if command is not implemented', function() - eq("Command not implemented: popup", pcall_err(meths.cmd, { cmd = "popup" }, {})) + eq("Command not implemented: winpos", pcall_err(meths.cmd, { cmd = "winpos" }, {})) end) it('works with empty arguments list', function() meths.cmd({ cmd = "update" }, {}) |