1" Tests for bracketed paste and other forms of pasting. 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_clipboard() 70 if !has('clipboard') 71 return 72 endif 73 let @+ = "nasty\<Esc>:!ls\<CR>command" 74 new 75 exe "normal i\<C-R>+\<Esc>" 76 call assert_equal("nasty\<Esc>:!ls\<CR>command", getline(1)) 77 bwipe! 78endfunc 79 80func Test_paste_cmdline() 81 call feedkeys(":a\<Esc>[200~foo\<CR>bar\<Esc>[201~b\<Home>\"\<CR>", 'xt') 82 call assert_equal("\"afoo\<CR>barb", getreg(':')) 83endfunc 84 85func Test_paste_visual_mode() 86 new 87 call setline(1, 'here are some words') 88 call feedkeys("0fsve\<Esc>[200~more\<Esc>[201~", 'xt') 89 call assert_equal('here are more words', getline(1)) 90 call assert_equal('some', getreg('-')) 91 92 " include last char in the line 93 call feedkeys("0fwve\<Esc>[200~noises\<Esc>[201~", 'xt') 94 call assert_equal('here are more noises', getline(1)) 95 call assert_equal('words', getreg('-')) 96 97 " exclude last char in the line 98 call setline(1, 'some words!') 99 call feedkeys("0fwve\<Esc>[200~noises\<Esc>[201~", 'xt') 100 call assert_equal('some noises!', getline(1)) 101 call assert_equal('words', getreg('-')) 102 103 " multi-line selection 104 call setline(1, ['some words', 'and more']) 105 call feedkeys("0fwvj0fd\<Esc>[200~letters\<Esc>[201~", 'xt') 106 call assert_equal('some letters more', getline(1)) 107 call assert_equal("words\nand", getreg('1')) 108 109 bwipe! 110endfunc 111