diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/api/window_spec.lua | 15 | ||||
-rw-r--r-- | test/functional/lua/snippet_spec.lua | 27 | ||||
-rw-r--r-- | test/functional/ui/cmdline_spec.lua | 23 |
3 files changed, 63 insertions, 2 deletions
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index a10c8f48ef..721148faaa 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -219,6 +219,21 @@ describe('API/win', function() -- curwin didn't change back neq(win, curwin()) + + -- shows updated position after getchar() #20793 + feed(':call getchar()<CR>') + api.nvim_win_set_cursor(win, { 1, 5 }) + screen:expect { + grid = [[ + | + {1:~ }|*2 + {2:[No Name] }| + prolo^gue | + |*2 + {3:[No Name] [+] }| + :call getchar() | + ]], + } end) it('remembers what column it wants to be in', function() diff --git a/test/functional/lua/snippet_spec.lua b/test/functional/lua/snippet_spec.lua index e981bc6261..d31b8cc7d5 100644 --- a/test/functional/lua/snippet_spec.lua +++ b/test/functional/lua/snippet_spec.lua @@ -5,6 +5,7 @@ local clear = helpers.clear local eq = helpers.eq local exec_lua = helpers.exec_lua local feed = helpers.feed +local api = helpers.api local fn = helpers.fn local matches = helpers.matches local pcall_err = helpers.pcall_err @@ -230,7 +231,7 @@ describe('vim.snippet', function() end) it('updates snippet state when built-in completion menu is visible', function() - test_expand_success({ '$1 = function($2)\n$3\nend' }, { ' = function()', '', 'end' }) + test_expand_success({ '$1 = function($2)\nend' }, { ' = function()', 'end' }) -- Show the completion menu. feed('<C-n>') -- Make sure no item is selected. @@ -238,6 +239,28 @@ describe('vim.snippet', function() -- Jump forward (the 2nd tabstop). exec_lua('vim.snippet.jump(1)') feed('foo') - eq({ ' = function(foo)', '', 'end' }, buf_lines(0)) + eq({ ' = function(foo)', 'end' }, buf_lines(0)) + end) + + it('correctly indents with newlines', function() + local curbuf = api.nvim_get_current_buf() + test_expand_success( + { 'function($2)\n$3\nend' }, + { 'function()', ' ', 'end' }, + [[ + vim.opt.sw = 2 + vim.opt.expandtab = true + ]] + ) + api.nvim_buf_set_lines(curbuf, 0, -1, false, {}) + test_expand_success( + { 'func main() {\n$1\n}' }, + { 'func main() {', '\t', '}' }, + [[ + vim.opt.sw = 4 + vim.opt.ts = 4 + vim.opt.expandtab = false + ]] + ) end) end) diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 0eb5770819..3b5b488982 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -824,6 +824,29 @@ local function test_cmdline(linegrid) | ]]) end) + + it('does not move cursor to curwin #20309', function() + local win = api.nvim_get_current_win() + command('norm icmdlinewin') + command('new') + command('norm icurwin') + feed(':') + api.nvim_win_set_cursor(win, { 1, 7 }) + screen:expect { + grid = [[ + curwin | + {3:[No Name] [+] }| + cmdline^win | + {2:[No Name] [+] }| + | + ]], + cmdline = { { + content = { { '' } }, + firstc = ':', + pos = 0, + } }, + } + end) end -- the representation of cmdline and cmdline_block contents changed with ext_linegrid |