2021-09-17 09:16:40 -07:00
|
|
|
|
-- Cmdline-mode tests.
|
|
|
|
|
|
2024-04-20 08:44:13 -07:00
|
|
|
|
local t = require('test.testutil')
|
|
|
|
|
local n = require('test.functional.testnvim')()
|
2023-11-27 20:46:20 -07:00
|
|
|
|
local Screen = require('test.functional.ui.screen')
|
2024-04-20 08:44:13 -07:00
|
|
|
|
|
|
|
|
|
local clear, insert, fn, eq, feed = n.clear, n.insert, n.fn, t.eq, n.feed
|
|
|
|
|
local eval = n.eval
|
|
|
|
|
local command = n.command
|
|
|
|
|
local api = n.api
|
2021-09-17 09:16:40 -07:00
|
|
|
|
|
2022-04-26 22:02:55 -07:00
|
|
|
|
describe('cmdline', function()
|
2021-09-17 09:16:40 -07:00
|
|
|
|
before_each(clear)
|
|
|
|
|
|
2022-04-26 22:02:55 -07:00
|
|
|
|
describe('Ctrl-R', function()
|
|
|
|
|
it('pasting non-special register inserts <CR> *between* lines', function()
|
|
|
|
|
insert([[
|
|
|
|
|
line1abc
|
|
|
|
|
line2somemoretext
|
|
|
|
|
]])
|
|
|
|
|
-- Yank 2 lines linewise, then paste to cmdline.
|
|
|
|
|
feed([[<C-\><C-N>gg0yj:<C-R>0]])
|
|
|
|
|
-- <CR> inserted between lines, NOT after the final line.
|
2024-01-12 10:59:57 -07:00
|
|
|
|
eq('line1abc\rline2somemoretext', fn.getcmdline())
|
2021-09-17 09:16:40 -07:00
|
|
|
|
|
2022-04-26 22:02:55 -07:00
|
|
|
|
-- Yank 2 lines charwise, then paste to cmdline.
|
|
|
|
|
feed([[<C-\><C-N>gg05lyvj:<C-R>0]])
|
|
|
|
|
-- <CR> inserted between lines, NOT after the final line.
|
2024-01-12 10:59:57 -07:00
|
|
|
|
eq('abc\rline2', fn.getcmdline())
|
2021-09-17 09:16:40 -07:00
|
|
|
|
|
2022-04-26 22:02:55 -07:00
|
|
|
|
-- Yank 1 line linewise, then paste to cmdline.
|
|
|
|
|
feed([[<C-\><C-N>ggyy:<C-R>0]])
|
|
|
|
|
-- No <CR> inserted.
|
2024-01-12 10:59:57 -07:00
|
|
|
|
eq('line1abc', fn.getcmdline())
|
2022-04-26 22:02:55 -07:00
|
|
|
|
end)
|
2021-09-17 09:16:40 -07:00
|
|
|
|
|
2022-04-26 22:02:55 -07:00
|
|
|
|
it('pasting special register inserts <CR>, <NL>', function()
|
|
|
|
|
feed([[:<C-R>="foo\nbar\rbaz"<CR>]])
|
2024-01-12 10:59:57 -07:00
|
|
|
|
eq('foo\nbar\rbaz', fn.getcmdline())
|
2022-04-26 22:02:55 -07:00
|
|
|
|
end)
|
2024-11-04 06:07:10 -07:00
|
|
|
|
|
|
|
|
|
it('pasting handles composing chars properly', function()
|
|
|
|
|
local screen = Screen.new(60, 4)
|
|
|
|
|
-- 'arabicshape' cheats and always redraws everything which trivially works,
|
|
|
|
|
-- this test is for partial redraws in 'noarabicshape' mode.
|
|
|
|
|
command('set noarabicshape')
|
|
|
|
|
fn.setreg('a', '💻')
|
|
|
|
|
feed(':test 🧑')
|
|
|
|
|
screen:expect([[
|
|
|
|
|
|
|
|
|
|
|
{1:~ }|*2
|
|
|
|
|
:test 🧑^ |
|
|
|
|
|
]])
|
|
|
|
|
feed('<c-r><c-r>a')
|
|
|
|
|
screen:expect([[
|
|
|
|
|
|
|
|
|
|
|
{1:~ }|*2
|
|
|
|
|
:test 🧑💻^ |
|
|
|
|
|
]])
|
|
|
|
|
end)
|
2021-09-17 09:16:40 -07:00
|
|
|
|
end)
|
viminfo: First version of ShaDa file dumping
What works:
1. ShaDa file dumping: header, registers, jump list, history, search patterns,
substitute strings, variables.
2. ShaDa file reading: registers, global marks, variables.
Most was not tested.
TODO:
1. Merging.
2. Reading history, local marks, jump and buffer lists.
3. Documentation update.
4. Converting some data from &encoding.
5. Safer variant of dumping viminfo (dump to temporary file then rename).
6. Removing old viminfo code (currently masked with `#if 0` in a ShaDa file for
reference).
2015-04-25 08:47:31 -07:00
|
|
|
|
|
2022-04-26 22:02:55 -07:00
|
|
|
|
it('Ctrl-Shift-V supports entering unsimplified key notations', function()
|
|
|
|
|
feed(':"<C-S-V><C-J><C-S-V><C-@><C-S-V><C-[><C-S-V><C-S-M><C-S-V><M-C-I><C-S-V><C-D-J><CR>')
|
viminfo: First version of ShaDa file dumping
What works:
1. ShaDa file dumping: header, registers, jump list, history, search patterns,
substitute strings, variables.
2. ShaDa file reading: registers, global marks, variables.
Most was not tested.
TODO:
1. Merging.
2. Reading history, local marks, jump and buffer lists.
3. Documentation update.
4. Converting some data from &encoding.
5. Safer variant of dumping viminfo (dump to temporary file then rename).
6. Removing old viminfo code (currently masked with `#if 0` in a ShaDa file for
reference).
2015-04-25 08:47:31 -07:00
|
|
|
|
|
2022-04-26 22:02:55 -07:00
|
|
|
|
eq('"<C-J><C-@><C-[><C-S-M><M-C-I><C-D-J>', eval('@:'))
|
viminfo: First version of ShaDa file dumping
What works:
1. ShaDa file dumping: header, registers, jump list, history, search patterns,
substitute strings, variables.
2. ShaDa file reading: registers, global marks, variables.
Most was not tested.
TODO:
1. Merging.
2. Reading history, local marks, jump and buffer lists.
3. Documentation update.
4. Converting some data from &encoding.
5. Safer variant of dumping viminfo (dump to temporary file then rename).
6. Removing old viminfo code (currently masked with `#if 0` in a ShaDa file for
reference).
2015-04-25 08:47:31 -07:00
|
|
|
|
end)
|
|
|
|
|
|
2023-11-27 20:46:20 -07:00
|
|
|
|
it('redraws statusline when toggling overstrike', function()
|
|
|
|
|
local screen = Screen.new(60, 4)
|
|
|
|
|
command('set laststatus=2 statusline=%!mode(1)')
|
|
|
|
|
feed(':')
|
|
|
|
|
screen:expect {
|
|
|
|
|
grid = [[
|
|
|
|
|
|
|
2024-05-26 00:34:29 -07:00
|
|
|
|
{1:~ }|
|
|
|
|
|
{3:c }|
|
2023-11-27 20:46:20 -07:00
|
|
|
|
:^ |
|
|
|
|
|
]],
|
|
|
|
|
}
|
|
|
|
|
feed('<Insert>')
|
|
|
|
|
screen:expect {
|
|
|
|
|
grid = [[
|
|
|
|
|
|
|
2024-05-26 00:34:29 -07:00
|
|
|
|
{1:~ }|
|
|
|
|
|
{3:cr }|
|
2023-11-27 20:46:20 -07:00
|
|
|
|
:^ |
|
|
|
|
|
]],
|
|
|
|
|
}
|
|
|
|
|
end)
|
|
|
|
|
|
2022-04-26 22:02:55 -07:00
|
|
|
|
describe('history', function()
|
|
|
|
|
it('correctly clears start of the history', function()
|
|
|
|
|
-- Regression test: check absence of the memory leak when clearing start of
|
2023-12-27 19:28:48 -07:00
|
|
|
|
-- the history using cmdhist.c/clr_history().
|
2024-01-12 10:59:57 -07:00
|
|
|
|
eq(1, fn.histadd(':', 'foo'))
|
|
|
|
|
eq(1, fn.histdel(':'))
|
|
|
|
|
eq('', fn.histget(':', -1))
|
2022-04-26 22:02:55 -07:00
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it('correctly clears end of the history', function()
|
|
|
|
|
-- Regression test: check absence of the memory leak when clearing end of
|
2023-12-27 19:28:48 -07:00
|
|
|
|
-- the history using cmdhist.c/clr_history().
|
2024-01-12 10:59:57 -07:00
|
|
|
|
api.nvim_set_option_value('history', 1, {})
|
|
|
|
|
eq(1, fn.histadd(':', 'foo'))
|
|
|
|
|
eq(1, fn.histdel(':'))
|
|
|
|
|
eq('', fn.histget(':', -1))
|
2022-04-26 22:02:55 -07:00
|
|
|
|
end)
|
viminfo: First version of ShaDa file dumping
What works:
1. ShaDa file dumping: header, registers, jump list, history, search patterns,
substitute strings, variables.
2. ShaDa file reading: registers, global marks, variables.
Most was not tested.
TODO:
1. Merging.
2. Reading history, local marks, jump and buffer lists.
3. Documentation update.
4. Converting some data from &encoding.
5. Safer variant of dumping viminfo (dump to temporary file then rename).
6. Removing old viminfo code (currently masked with `#if 0` in a ShaDa file for
reference).
2015-04-25 08:47:31 -07:00
|
|
|
|
|
2022-04-26 22:02:55 -07:00
|
|
|
|
it('correctly removes item from history', function()
|
2023-12-27 19:28:48 -07:00
|
|
|
|
-- Regression test: check that cmdhist.c/del_history_idx() correctly clears
|
2022-04-26 22:02:55 -07:00
|
|
|
|
-- history index after removing history entry. If it does not then deleting
|
|
|
|
|
-- history will result in a double free.
|
2024-01-12 10:59:57 -07:00
|
|
|
|
eq(1, fn.histadd(':', 'foo'))
|
|
|
|
|
eq(1, fn.histadd(':', 'bar'))
|
|
|
|
|
eq(1, fn.histadd(':', 'baz'))
|
|
|
|
|
eq(1, fn.histdel(':', -2))
|
|
|
|
|
eq(1, fn.histdel(':'))
|
|
|
|
|
eq('', fn.histget(':', -1))
|
2022-04-26 22:02:55 -07:00
|
|
|
|
end)
|
viminfo: First version of ShaDa file dumping
What works:
1. ShaDa file dumping: header, registers, jump list, history, search patterns,
substitute strings, variables.
2. ShaDa file reading: registers, global marks, variables.
Most was not tested.
TODO:
1. Merging.
2. Reading history, local marks, jump and buffer lists.
3. Documentation update.
4. Converting some data from &encoding.
5. Safer variant of dumping viminfo (dump to temporary file then rename).
6. Removing old viminfo code (currently masked with `#if 0` in a ShaDa file for
reference).
2015-04-25 08:47:31 -07:00
|
|
|
|
end)
|
|
|
|
|
end)
|