1" Tests for bracketed paste. 2 3" Bracketed paste only works with "xterm". Not in GUI. 4if has('gui_running') 5 finish 6endif 7set term=xterm 8 9func Test_paste_normal_mode() 10 new 11 " In first column text is inserted 12 call setline(1, ['a', 'b', 'c']) 13 call cursor(2, 1) 14 call feedkeys("\<Esc>[200~foo\<CR>bar\<Esc>[201~", 'xt') 15 call assert_equal('foo', getline(2)) 16 call assert_equal('barb', getline(3)) 17 call assert_equal('c', getline(4)) 18 19 " When repeating text is appended 20 normal . 21 call assert_equal('barfoo', getline(3)) 22 call assert_equal('barb', getline(4)) 23 call assert_equal('c', getline(5)) 24 bwipe! 25 26 " In second column text is appended 27 call setline(1, ['a', 'bbb', 'c']) 28 call cursor(2, 2) 29 call feedkeys("\<Esc>[200~foo\<CR>bar\<Esc>[201~", 'xt') 30 call assert_equal('bbfoo', getline(2)) 31 call assert_equal('barb', getline(3)) 32 call assert_equal('c', getline(4)) 33 34 " In last column text is appended 35 call setline(1, ['a', 'bbb', 'c']) 36 call cursor(2, 3) 37 call feedkeys("\<Esc>[200~foo\<CR>bar\<Esc>[201~", 'xt') 38 call assert_equal('bbbfoo', getline(2)) 39 call assert_equal('bar', getline(3)) 40 call assert_equal('c', getline(4)) 41endfunc 42 43func Test_paste_insert_mode() 44 new 45 call setline(1, ['a', 'b', 'c']) 46 2 47 call feedkeys("i\<Esc>[200~foo\<CR>bar\<Esc>[201~ done\<Esc>", 'xt') 48 call assert_equal('foo', getline(2)) 49 call assert_equal('bar doneb', getline(3)) 50 call assert_equal('c', getline(4)) 51 52 normal . 53 call assert_equal('bar donfoo', getline(3)) 54 call assert_equal('bar doneeb', getline(4)) 55 call assert_equal('c', getline(5)) 56 57 set ai et tw=10 58 call setline(1, ['a', ' b', 'c']) 59 2 60 call feedkeys("A\<Esc>[200~foo\<CR> bar bar bar\<Esc>[201~\<Esc>", 'xt') 61 call assert_equal(' bfoo', getline(2)) 62 call assert_equal(' bar bar bar', getline(3)) 63 call assert_equal('c', getline(4)) 64 65 set ai& et& tw=0 66 bwipe! 67endfunc 68 69func Test_paste_cmdline() 70 call feedkeys(":a\<Esc>[200~foo\<CR>bar\<Esc>[201~b\<Home>\"\<CR>", 'xt') 71 call assert_equal("\"afoo\<CR>barb", getreg(':')) 72endfunc 73 74func Test_paste_visual_mode() 75 new 76 call setline(1, 'here are some words') 77 call feedkeys("0fsve\<Esc>[200~more\<Esc>[201~", 'xt') 78 call assert_equal('here are more words', getline(1)) 79 call assert_equal('some', getreg('-')) 80 81 " include last char in the line 82 call feedkeys("0fwve\<Esc>[200~noises\<Esc>[201~", 'xt') 83 call assert_equal('here are more noises', getline(1)) 84 call assert_equal('words', getreg('-')) 85 86 " exclude last char in the line 87 call setline(1, 'some words!') 88 call feedkeys("0fwve\<Esc>[200~noises\<Esc>[201~", 'xt') 89 call assert_equal('some noises!', getline(1)) 90 call assert_equal('words', getreg('-')) 91 92 " multi-line selection 93 call setline(1, ['some words', 'and more']) 94 call feedkeys("0fwvj0fd\<Esc>[200~letters\<Esc>[201~", 'xt') 95 call assert_equal('some letters more', getline(1)) 96 call assert_equal("words\nand", getreg('1')) 97 98 bwipe! 99endfunc 100