2019-05-20 09:49:42 -07:00
|
|
|
" Tests for the changelist functionality
|
|
|
|
|
2022-07-22 18:27:31 -07:00
|
|
|
" When splitting a window the changelist position is wrong.
|
|
|
|
" Test the changelist position after splitting a window.
|
|
|
|
" Test for the bug fixed by 7.4.386
|
|
|
|
func Test_changelist()
|
|
|
|
let save_ul = &ul
|
|
|
|
enew!
|
|
|
|
call append('$', ['1', '2'])
|
|
|
|
exe "normal i\<C-G>u"
|
|
|
|
exe "normal Gkylpa\<C-G>u"
|
|
|
|
set ul=100
|
|
|
|
exe "normal Gylpa\<C-G>u"
|
|
|
|
set ul=100
|
|
|
|
normal gg
|
|
|
|
vsplit
|
|
|
|
normal g;
|
|
|
|
call assert_equal([3, 2], [line('.'), col('.')])
|
|
|
|
normal g;
|
|
|
|
call assert_equal([2, 2], [line('.'), col('.')])
|
|
|
|
call assert_fails('normal g;', 'E662:')
|
|
|
|
new
|
|
|
|
call assert_fails('normal g;', 'E664:')
|
|
|
|
%bwipe!
|
|
|
|
let &ul = save_ul
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
" Moving a split should not change its changelist index.
|
|
|
|
func Test_changelist_index_move_split()
|
|
|
|
exe "norm! iabc\<C-G>u\ndef\<C-G>u\nghi"
|
|
|
|
vsplit
|
|
|
|
normal 99g;
|
|
|
|
call assert_equal(0, getchangelist('%')[1])
|
|
|
|
wincmd L
|
|
|
|
call assert_equal(0, getchangelist('%')[1])
|
|
|
|
endfunc
|
|
|
|
|
2019-05-20 09:49:42 -07:00
|
|
|
" Tests for the getchangelist() function
|
2022-07-22 18:15:31 -07:00
|
|
|
func Test_changelist_index()
|
2023-11-12 18:08:02 -07:00
|
|
|
edit Xgclfile1.txt
|
2022-07-22 18:15:31 -07:00
|
|
|
exe "normal iabc\<C-G>u\ndef\<C-G>u\nghi"
|
|
|
|
call assert_equal(3, getchangelist('%')[1])
|
|
|
|
" Move one step back in the changelist.
|
|
|
|
normal 2g;
|
|
|
|
|
2023-11-12 18:08:02 -07:00
|
|
|
hide edit Xgclfile2.txt
|
2022-07-22 18:15:31 -07:00
|
|
|
exe "normal iabcd\<C-G>u\ndefg\<C-G>u\nghij"
|
|
|
|
call assert_equal(3, getchangelist('%')[1])
|
|
|
|
" Move to the beginning of the changelist.
|
|
|
|
normal 99g;
|
|
|
|
|
|
|
|
" Check the changelist indices.
|
|
|
|
call assert_equal(0, getchangelist('%')[1])
|
|
|
|
call assert_equal(1, getchangelist('#')[1])
|
2019-05-20 09:49:42 -07:00
|
|
|
|
2022-07-22 18:15:31 -07:00
|
|
|
bwipe!
|
2023-11-12 18:08:02 -07:00
|
|
|
call delete('Xgclfile1.txt')
|
|
|
|
call delete('Xgclfile2.txt')
|
2022-07-22 18:15:31 -07:00
|
|
|
endfunc
|
|
|
|
|
|
|
|
func Test_getchangelist()
|
2019-05-20 09:49:42 -07:00
|
|
|
bwipe!
|
|
|
|
enew
|
2021-08-27 13:09:37 -07:00
|
|
|
call assert_equal([], 10->getchangelist())
|
|
|
|
call assert_equal([[], 0], getchangelist())
|
2019-05-20 09:49:42 -07:00
|
|
|
|
2023-11-12 18:08:02 -07:00
|
|
|
call writefile(['line1', 'line2', 'line3'], 'Xclistfile1.txt')
|
|
|
|
call writefile(['line1', 'line2', 'line3'], 'Xclistfile2.txt')
|
2019-05-20 09:49:42 -07:00
|
|
|
|
2023-11-12 18:08:02 -07:00
|
|
|
edit Xclistfile1.txt
|
2022-07-22 18:15:31 -07:00
|
|
|
let buf_1 = bufnr()
|
2019-05-20 09:49:42 -07:00
|
|
|
exe "normal 1Goline\<C-G>u1.1"
|
|
|
|
exe "normal 3Goline\<C-G>u2.1"
|
|
|
|
exe "normal 5Goline\<C-G>u3.1"
|
|
|
|
normal g;
|
|
|
|
call assert_equal([[
|
|
|
|
\ {'lnum' : 2, 'col' : 4, 'coladd' : 0},
|
|
|
|
\ {'lnum' : 4, 'col' : 4, 'coladd' : 0},
|
|
|
|
\ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 2],
|
2019-05-20 10:34:48 -07:00
|
|
|
\ getchangelist('%'))
|
2019-05-20 09:49:42 -07:00
|
|
|
|
2023-11-12 18:08:02 -07:00
|
|
|
hide edit Xclistfile2.txt
|
2022-07-22 18:15:31 -07:00
|
|
|
let buf_2 = bufnr()
|
2019-05-20 09:49:42 -07:00
|
|
|
exe "normal 1GOline\<C-G>u1.0"
|
|
|
|
exe "normal 2Goline\<C-G>u2.0"
|
|
|
|
call assert_equal([[
|
|
|
|
\ {'lnum' : 1, 'col' : 6, 'coladd' : 0},
|
|
|
|
\ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2],
|
2019-05-20 10:34:48 -07:00
|
|
|
\ getchangelist('%'))
|
2019-05-20 09:49:42 -07:00
|
|
|
hide enew
|
|
|
|
|
|
|
|
call assert_equal([[
|
|
|
|
\ {'lnum' : 2, 'col' : 4, 'coladd' : 0},
|
|
|
|
\ {'lnum' : 4, 'col' : 4, 'coladd' : 0},
|
2022-07-22 18:15:31 -07:00
|
|
|
\ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 2],
|
|
|
|
\ getchangelist(buf_1))
|
2019-05-20 09:49:42 -07:00
|
|
|
call assert_equal([[
|
|
|
|
\ {'lnum' : 1, 'col' : 6, 'coladd' : 0},
|
2022-07-22 18:15:31 -07:00
|
|
|
\ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2],
|
|
|
|
\ getchangelist(buf_2))
|
2019-05-20 09:49:42 -07:00
|
|
|
|
|
|
|
bwipe!
|
2023-11-12 18:08:02 -07:00
|
|
|
call delete('Xclistfile1.txt')
|
|
|
|
call delete('Xclistfile2.txt')
|
2019-05-20 09:49:42 -07:00
|
|
|
endfunc
|
2022-07-12 22:47:01 -07:00
|
|
|
|
|
|
|
" vim: shiftwidth=2 sts=2 expandtab
|