mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
tests: Don't set ul in migrated test 61.
The legacy test uses `set ul=100` to break the changes into blocks that can be undone separately. This is needed because the legacy test is sourced from a file and changes would be grouped into on undo block by default. The lua test suite does not have this restriction. Also add a new test case to test this effect of using `set ul=100` in a sourced script.
This commit is contained in:
parent
8c999a9d6c
commit
981dd23f8d
@ -1,13 +1,16 @@
|
|||||||
-- Tests for undo tree.
|
-- Tests for undo tree and :earlier and :later.
|
||||||
-- Since this script is sourced we need to explicitly break changes up in
|
|
||||||
-- undo-able pieces. Do that by setting 'undolevels'.
|
|
||||||
-- Also tests :earlier and :later.
|
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local feed, insert, source, eq, eval, clear, execute, expect, wait =
|
local feed, insert, source, eq, eval, clear, execute, expect, wait =
|
||||||
helpers.feed, helpers.insert, helpers.source, helpers.eq, helpers.eval,
|
helpers.feed, helpers.insert, helpers.source, helpers.eq, helpers.eval,
|
||||||
helpers.clear, helpers.execute, helpers.expect, helpers.wait
|
helpers.clear, helpers.execute, helpers.expect, helpers.wait
|
||||||
|
|
||||||
|
local expect_empty_buffer = function()
|
||||||
|
-- The space will be removed by helpers.dedent but is needed as dedent will
|
||||||
|
-- throw an error if it can not find the common indent of the given lines.
|
||||||
|
expect(' ')
|
||||||
|
end
|
||||||
|
|
||||||
describe('the undo tree', function()
|
describe('the undo tree', function()
|
||||||
setup(clear)
|
setup(clear)
|
||||||
teardown(function()
|
teardown(function()
|
||||||
@ -30,11 +33,7 @@ describe('the undo tree', function()
|
|||||||
eq({}, eval('undotree().entries'))
|
eq({}, eval('undotree().entries'))
|
||||||
|
|
||||||
-- Delete three characters and undo.
|
-- Delete three characters and undo.
|
||||||
feed('Gx')
|
feed('Gxxx')
|
||||||
execute('set ul=100')
|
|
||||||
feed('x')
|
|
||||||
execute('set ul=100')
|
|
||||||
feed('x')
|
|
||||||
eq('456789', eval('getline(".")'))
|
eq('456789', eval('getline(".")'))
|
||||||
feed('g-')
|
feed('g-')
|
||||||
eq('3456789', eval('getline(".")'))
|
eq('3456789', eval('getline(".")'))
|
||||||
@ -46,11 +45,7 @@ describe('the undo tree', function()
|
|||||||
eq('123456789', eval('getline(".")'))
|
eq('123456789', eval('getline(".")'))
|
||||||
|
|
||||||
-- Delete three other characters and go back in time step by step.
|
-- Delete three other characters and go back in time step by step.
|
||||||
feed('$x')
|
feed('$xxx')
|
||||||
execute('set ul=100')
|
|
||||||
feed('x')
|
|
||||||
execute('set ul=100')
|
|
||||||
feed('x')
|
|
||||||
eq('123456', eval('getline(".")'))
|
eq('123456', eval('getline(".")'))
|
||||||
execute('sleep 1')
|
execute('sleep 1')
|
||||||
wait()
|
wait()
|
||||||
@ -77,11 +72,8 @@ describe('the undo tree', function()
|
|||||||
execute('sleep 2')
|
execute('sleep 2')
|
||||||
wait()
|
wait()
|
||||||
feed('Aa<esc>')
|
feed('Aa<esc>')
|
||||||
execute('set ul=100')
|
|
||||||
feed('Ab<esc>')
|
feed('Ab<esc>')
|
||||||
execute('set ul=100')
|
|
||||||
feed('Ac<esc>')
|
feed('Ac<esc>')
|
||||||
execute('set ul=100')
|
|
||||||
eq('123456abc', eval('getline(".")'))
|
eq('123456abc', eval('getline(".")'))
|
||||||
execute('ear 1s')
|
execute('ear 1s')
|
||||||
eq('123456', eval('getline(".")'))
|
eq('123456', eval('getline(".")'))
|
||||||
@ -92,13 +84,47 @@ describe('the undo tree', function()
|
|||||||
execute('later 1h')
|
execute('later 1h')
|
||||||
eq('123456abc', eval('getline(".")'))
|
eq('123456abc', eval('getline(".")'))
|
||||||
|
|
||||||
|
-- Test that setting 'ul' breaks change blocks, we need to use source() in
|
||||||
|
-- order to test this, as interactive changes are not grouped.
|
||||||
|
execute('new')
|
||||||
|
-- First verify that scripts produce single big undo blocks.
|
||||||
|
source([[
|
||||||
|
normal Aaaaa
|
||||||
|
normal obbbb
|
||||||
|
normal occcc
|
||||||
|
]])
|
||||||
|
expect([[
|
||||||
|
aaaa
|
||||||
|
bbbb
|
||||||
|
cccc]])
|
||||||
|
feed('u')
|
||||||
|
expect_empty_buffer()
|
||||||
|
-- Verify that undo blocks can be broken inside scripts by setting 'ul'.
|
||||||
|
source([[
|
||||||
|
normal Aaaaa
|
||||||
|
set ul=100
|
||||||
|
normal obbbb
|
||||||
|
set ul=100
|
||||||
|
normal occcc
|
||||||
|
]])
|
||||||
|
expect([[
|
||||||
|
aaaa
|
||||||
|
bbbb
|
||||||
|
cccc]])
|
||||||
|
feed('u')
|
||||||
|
expect([[
|
||||||
|
aaaa
|
||||||
|
bbbb]])
|
||||||
|
feed('u')
|
||||||
|
expect('aaaa')
|
||||||
|
feed('u')
|
||||||
|
expect_empty_buffer()
|
||||||
|
|
||||||
-- Test undojoin.
|
-- Test undojoin.
|
||||||
feed('Goaaaa<esc>')
|
feed('Goaaaa<esc>')
|
||||||
execute('set ul=100')
|
|
||||||
feed('obbbb<esc>u')
|
feed('obbbb<esc>u')
|
||||||
eq('aaaa', eval('getline(".")'))
|
eq('aaaa', eval('getline(".")'))
|
||||||
feed('obbbb<esc>')
|
feed('obbbb<esc>')
|
||||||
execute('set ul=100')
|
|
||||||
execute('undojoin')
|
execute('undojoin')
|
||||||
feed('occcc<esc>u')
|
feed('occcc<esc>u')
|
||||||
-- TODO At this point the original test will write "aaaa" to test.out.
|
-- TODO At this point the original test will write "aaaa" to test.out.
|
||||||
@ -107,12 +133,9 @@ describe('the undo tree', function()
|
|||||||
|
|
||||||
execute('e! Xtest')
|
execute('e! Xtest')
|
||||||
feed('ione one one<esc>')
|
feed('ione one one<esc>')
|
||||||
execute('set ul=100')
|
|
||||||
execute('w!')
|
execute('w!')
|
||||||
feed('otwo<esc>')
|
feed('otwo<esc>')
|
||||||
execute('set ul=100')
|
|
||||||
feed('otwo<esc>')
|
feed('otwo<esc>')
|
||||||
execute('set ul=100')
|
|
||||||
execute('w')
|
execute('w')
|
||||||
feed('othree<esc>')
|
feed('othree<esc>')
|
||||||
execute('earlier 1f')
|
execute('earlier 1f')
|
||||||
@ -123,9 +146,7 @@ describe('the undo tree', function()
|
|||||||
execute('earlier 1f')
|
execute('earlier 1f')
|
||||||
expect('one one one')
|
expect('one one one')
|
||||||
execute('earlier 1f')
|
execute('earlier 1f')
|
||||||
-- Expect an empty line (the space is needed for helpers.dedent but
|
expect_empty_buffer()
|
||||||
-- removed).
|
|
||||||
expect(' ')
|
|
||||||
execute('later 1f')
|
execute('later 1f')
|
||||||
expect('one one one')
|
expect('one one one')
|
||||||
execute('later 1f')
|
execute('later 1f')
|
||||||
@ -142,9 +163,7 @@ describe('the undo tree', function()
|
|||||||
|
|
||||||
execute('enew!')
|
execute('enew!')
|
||||||
feed('oa<esc>')
|
feed('oa<esc>')
|
||||||
execute('set ul=100')
|
|
||||||
feed('ob<esc>')
|
feed('ob<esc>')
|
||||||
execute('set ul=100')
|
|
||||||
feed([[o1<esc>a2<C-R>=setline('.','1234')<cr><esc>]])
|
feed([[o1<esc>a2<C-R>=setline('.','1234')<cr><esc>]])
|
||||||
expect([[
|
expect([[
|
||||||
|
|
||||||
@ -159,7 +178,6 @@ describe('the undo tree', function()
|
|||||||
b
|
b
|
||||||
1]])
|
1]])
|
||||||
feed('oc<esc>')
|
feed('oc<esc>')
|
||||||
execute('set ul=100')
|
|
||||||
feed([[o1<esc>a2<C-R>=setline('.','1234')<cr><esc>]])
|
feed([[o1<esc>a2<C-R>=setline('.','1234')<cr><esc>]])
|
||||||
expect([[
|
expect([[
|
||||||
|
|
||||||
@ -177,7 +195,6 @@ describe('the undo tree', function()
|
|||||||
c
|
c
|
||||||
12]])
|
12]])
|
||||||
feed('od<esc>')
|
feed('od<esc>')
|
||||||
execute('set ul=100')
|
|
||||||
feed('o1<esc>a2<C-R>=string(123)<cr><esc>')
|
feed('o1<esc>a2<C-R>=string(123)<cr><esc>')
|
||||||
expect([[
|
expect([[
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user