2024-04-20 08:44:13 -07:00
|
|
|
local n = require('test.functional.testnvim')()
|
2022-11-04 04:49:23 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2024-04-20 08:44:13 -07:00
|
|
|
|
|
|
|
local clear = n.clear
|
|
|
|
local command = n.command
|
|
|
|
local expect = n.expect
|
|
|
|
local feed = n.feed
|
2024-01-12 04:41:09 -07:00
|
|
|
local sleep = vim.uv.sleep
|
2022-07-16 06:56:47 -07:00
|
|
|
|
|
|
|
before_each(clear)
|
|
|
|
|
2022-11-04 04:49:23 -07:00
|
|
|
describe('edit', function()
|
|
|
|
-- oldtest: Test_autoindent_remove_indent()
|
|
|
|
it('autoindent removes indent when Insert mode is stopped', function()
|
|
|
|
command('set autoindent')
|
|
|
|
-- leaving insert mode in a new line with indent added by autoindent, should
|
|
|
|
-- remove the indent.
|
|
|
|
feed('i<Tab>foo<CR><Esc>')
|
|
|
|
-- Need to delay for sometime, otherwise the code in getchar.c will not be
|
|
|
|
-- exercised.
|
|
|
|
sleep(50)
|
|
|
|
-- when a line is wrapped and the cursor is at the start of the second line,
|
|
|
|
-- leaving insert mode, should move the cursor back to the first line.
|
|
|
|
feed('o' .. ('x'):rep(20) .. '<Esc>')
|
|
|
|
-- Need to delay for sometime, otherwise the code in getchar.c will not be
|
|
|
|
-- exercised.
|
|
|
|
sleep(50)
|
|
|
|
expect('\tfoo\n\n' .. ('x'):rep(20))
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- oldtest: Test_edit_insert_reg()
|
|
|
|
it('inserting a register using CTRL-R', function()
|
|
|
|
local screen = Screen.new(10, 6)
|
|
|
|
feed('a<C-R>')
|
|
|
|
screen:expect([[
|
2024-03-27 02:35:50 -07:00
|
|
|
{18:^"} |
|
|
|
|
{1:~ }|*4
|
|
|
|
{5:-- INSERT --}|
|
2022-11-04 04:49:23 -07:00
|
|
|
]])
|
|
|
|
feed('=')
|
|
|
|
screen:expect([[
|
2024-03-27 02:35:50 -07:00
|
|
|
{18:"} |
|
|
|
|
{1:~ }|*4
|
2022-11-04 04:49:23 -07:00
|
|
|
=^ |
|
|
|
|
]])
|
2024-07-29 22:38:13 -07:00
|
|
|
feed([['r'<CR><Esc>]])
|
|
|
|
expect('r')
|
|
|
|
-- Test for inserting null and empty list
|
|
|
|
feed('a<C-R>=v:_null_list<CR><Esc>')
|
|
|
|
feed('a<C-R>=[]<CR><Esc>')
|
|
|
|
expect('r')
|
2022-11-04 04:49:23 -07:00
|
|
|
end)
|
2023-03-25 18:24:04 -07:00
|
|
|
|
|
|
|
-- oldtest: Test_edit_ctrl_r_failed()
|
|
|
|
it('positioning cursor after CTRL-R expression failed', function()
|
|
|
|
local screen = Screen.new(60, 6)
|
|
|
|
|
|
|
|
feed('i<C-R>')
|
|
|
|
screen:expect([[
|
2024-03-27 02:35:50 -07:00
|
|
|
{18:^"} |
|
|
|
|
{1:~ }|*4
|
|
|
|
{5:-- INSERT --} |
|
2023-03-25 18:24:04 -07:00
|
|
|
]])
|
2024-04-14 16:11:39 -07:00
|
|
|
feed('=0z')
|
2023-03-25 18:24:04 -07:00
|
|
|
screen:expect([[
|
2024-03-27 02:35:50 -07:00
|
|
|
{18:"} |
|
|
|
|
{1:~ }|*4
|
2024-04-14 16:11:39 -07:00
|
|
|
={26:0}{9:z}^ |
|
2023-03-25 18:24:04 -07:00
|
|
|
]])
|
2024-04-14 16:11:39 -07:00
|
|
|
-- trying to insert a blob produces an error
|
2023-03-25 18:24:04 -07:00
|
|
|
feed('<CR>')
|
|
|
|
screen:expect([[
|
2024-03-27 02:35:50 -07:00
|
|
|
{18:"} |
|
|
|
|
{1:~ }|
|
|
|
|
{3: }|
|
2024-04-14 16:11:39 -07:00
|
|
|
={26:0}{9:z} |
|
|
|
|
{9:E976: Using a Blob as a String} |
|
2023-03-25 18:24:04 -07:00
|
|
|
{6:Press ENTER or type command to continue}^ |
|
|
|
|
]])
|
|
|
|
|
|
|
|
feed(':')
|
|
|
|
screen:expect([[
|
|
|
|
:^ |
|
2024-03-27 02:35:50 -07:00
|
|
|
{1:~ }|*4
|
|
|
|
{5:-- INSERT --} |
|
2023-03-25 18:24:04 -07:00
|
|
|
]])
|
|
|
|
-- ending Insert mode should put the cursor back on the ':'
|
|
|
|
feed('<Esc>')
|
|
|
|
screen:expect([[
|
|
|
|
^: |
|
2024-03-27 02:35:50 -07:00
|
|
|
{1:~ }|*4
|
2023-03-25 18:24:04 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
2022-07-16 06:56:47 -07:00
|
|
|
end)
|