robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
8634ec3827
master
1" Test for block inserting 2" 3 4func Test_blockinsert_indent () 5new 6filetype plugin indent on 7setlocal sw = 2 et ft = vim 8call setline ( 1 , [ 'let a=[' , ' ''eins'',' , ' ''zwei'',' , ' ''drei'']' ]) 9call cursor ( 2 , 3 ) 10exe "norm! \<c-v>2jI\\ \<esc>" 11call assert_equal ([ 'let a=[' , ' \ ''eins'',' , ' \ ''zwei'',' , ' \ ''drei'']' ], 12 \getline ( 1 , '$' )) 13" reset to sane state 14filetype off 15bwipe ! 16endfunc 17 18func Test_blockinsert_autoindent () 19new 20let lines =<< trim END 21vim9script 22var d = { 23a: () => 0, 24b: () => 0, 25c: () => 0, 26} 27END 28call setline ( 1 , lines ) 29filetype plugin indent on 30setlocal sw = 2 et ft = vim 31setlocal indentkeys += : 32exe "norm! 3Gf)\<c-v>2jA: asdf\<esc>" 33let expected =<< trim END 34vim9script 35var d = { 36a: (): asdf => 0, 37b: (): asdf => 0, 38c: (): asdf => 0, 39} 40END 41call assert_equal ( expected , getline ( 1 , 6 )) 42 43" insert on the next column should do exactly the same 44: %dele 45call setline ( 1 , lines ) 46exe "norm! 3Gf)l\<c-v>2jI: asdf\<esc>" 47call assert_equal ( expected , getline ( 1 , 6 )) 48 49: %dele 50call setline ( 1 , lines ) 51setlocal sw = 8 noet 52exe "norm! 3Gf)\<c-v>2jA: asdf\<esc>" 53let expected =<< trim END 54vim9script 55var d = { 56a: (): asdf => 0, 57b: (): asdf => 0, 58c: (): asdf => 0, 59} 60END 61call assert_equal ( expected , getline ( 1 , 6 )) 62 63" insert on the next column should do exactly the same 64: %dele 65call setline ( 1 , lines ) 66exe "norm! 3Gf)l\<c-v>2jI: asdf\<esc>" 67call assert_equal ( expected , getline ( 1 , 6 )) 68 69filetype off 70bwipe ! 71endfunc 72 73func Test_blockinsert_delete () 74new 75let _bs = & bs 76set bs = 2 77call setline ( 1 , [ 'case Arg is ' , ' when Name_Async,' , ' when Name_Num_Gangs,' , 'end if;' ]) 78exe "norm! ggjVj\<c-v>$o$A\<bs>\<esc>" 79"call feedkeys("Vj\<c-v>$o$A\<bs>\<esc>", 'ti') 80call assert_equal ([ "case Arg is " , " when Name_Async" , " when Name_Num_Gangs," , "end if;" ], 81 \getline ( 1 , '$' )) 82" reset to sane state 83let & bs = _bs 84bwipe ! 85endfunc 86 87func Test_blockappend_eol_cursor () 88new 89" Test 1 Move 1 char left 90call setline ( 1 , [ 'aaa' , 'bbb' , 'ccc' ]) 91exe "norm! gg$\<c-v>2jA\<left>x\<esc>" 92call assert_equal ([ 'aaxa' , 'bbxb' , 'ccxc' ], getline ( 1 , '$' )) 93" Test 2 Move 2 chars left 94sil %d 95call setline ( 1 , [ 'aaa' , 'bbb' , 'ccc' ]) 96exe "norm! gg$\<c-v>2jA\<left>\<left>x\<esc>" 97call assert_equal ([ 'axaa' , 'bxbb' , 'cxcc' ], getline ( 1 , '$' )) 98" Test 3 Move 3 chars left (outside of the visual selection) 99sil %d 100call setline ( 1 , [ 'aaa' , 'bbb' , 'ccc' ]) 101exe "norm! ggl$\<c-v>2jA\<left>\<left>\<left>x\<esc>" 102call assert_equal ([ 'xaaa' , 'bbb' , 'ccc' ], getline ( 1 , '$' )) 103bw ! 104endfunc 105 106func Test_blockappend_eol_cursor2 () 107new 108" Test 1 Move 1 char left 109call setline ( 1 , [ 'aaaaa' , 'bbb' , 'ccccc' ]) 110exe "norm! gg\<c-v>$2jA\<left>x\<esc>" 111call assert_equal ([ 'aaaaxa' , 'bbbx' , 'ccccxc' ], getline ( 1 , '$' )) 112" Test 2 Move 2 chars left 113sil %d 114call setline ( 1 , [ 'aaaaa' , 'bbb' , 'ccccc' ]) 115exe "norm! gg\<c-v>$2jA\<left>\<left>x\<esc>" 116call assert_equal ([ 'aaaxaa' , 'bbbx' , 'cccxcc' ], getline ( 1 , '$' )) 117" Test 3 Move 3 chars left (to the beginning of the visual selection) 118sil %d 119call setline ( 1 , [ 'aaaaa' , 'bbb' , 'ccccc' ]) 120exe "norm! gg\<c-v>$2jA\<left>\<left>\<left>x\<esc>" 121call assert_equal ([ 'aaxaaa' , 'bbxb' , 'ccxccc' ], getline ( 1 , '$' )) 122" Test 4 Move 3 chars left (outside of the visual selection) 123sil %d 124call setline ( 1 , [ 'aaaaa' , 'bbb' , 'ccccc' ]) 125exe "norm! ggl\<c-v>$2jA\<left>\<left>\<left>x\<esc>" 126call assert_equal ([ 'aaxaaa' , 'bbxb' , 'ccxccc' ], getline ( 1 , '$' )) 127" Test 5 Move 4 chars left (outside of the visual selection) 128sil %d 129call setline ( 1 , [ 'aaaaa' , 'bbb' , 'ccccc' ]) 130exe "norm! ggl\<c-v>$2jA\<left>\<left>\<left>\<left>x\<esc>" 131call assert_equal ([ 'axaaaa' , 'bxbb' , 'cxcccc' ], getline ( 1 , '$' )) 132bw ! 133endfunc 134 135" vim: shiftwidth=2 sts=2 expandtab