Bram Moolenaar | f8eb9c5 | 2017-01-02 17:31:24 +0100 | [diff] [blame] | 1 | " Tests for various Visual mode. |
Bram Moolenaar | 019b9c6 | 2016-03-05 17:26:00 +0100 | [diff] [blame] | 2 | if !has('visual') |
| 3 | finish |
| 4 | endif |
| 5 | |
Bram Moolenaar | c3c766e | 2017-03-08 22:55:19 +0100 | [diff] [blame] | 6 | set belloff=all |
| 7 | |
Bram Moolenaar | 019b9c6 | 2016-03-05 17:26:00 +0100 | [diff] [blame] | 8 | func Test_block_shift_multibyte() |
Bram Moolenaar | f8eb9c5 | 2017-01-02 17:31:24 +0100 | [diff] [blame] | 9 | " Uses double-wide character. |
| 10 | if !has('multi_byte') |
| 11 | return |
| 12 | endif |
Bram Moolenaar | 019b9c6 | 2016-03-05 17:26:00 +0100 | [diff] [blame] | 13 | split |
| 14 | call setline(1, ['xヹxxx', 'ヹxxx']) |
| 15 | exe "normal 1G0l\<C-V>jl>" |
| 16 | call assert_equal('x ヹxxx', getline(1)) |
| 17 | call assert_equal(' ヹxxx', getline(2)) |
| 18 | q! |
| 19 | endfunc |
Bram Moolenaar | f8eb9c5 | 2017-01-02 17:31:24 +0100 | [diff] [blame] | 20 | |
Bram Moolenaar | bae5a17 | 2017-08-06 15:42:06 +0200 | [diff] [blame] | 21 | func Test_block_shift_overflow() |
| 22 | " This used to cause a multiplication overflow followed by a crash. |
| 23 | new |
| 24 | normal ii |
| 25 | exe "normal \<C-V>876543210>" |
| 26 | q! |
| 27 | endfunc |
| 28 | |
Bram Moolenaar | f8eb9c5 | 2017-01-02 17:31:24 +0100 | [diff] [blame] | 29 | func Test_dotregister_paste() |
| 30 | new |
| 31 | exe "norm! ihello world\<esc>" |
| 32 | norm! 0ve".p |
| 33 | call assert_equal('hello world world', getline(1)) |
| 34 | q! |
| 35 | endfunc |
Bram Moolenaar | 23fa81d | 2017-02-01 21:50:21 +0100 | [diff] [blame] | 36 | |
| 37 | func Test_Visual_ctrl_o() |
| 38 | new |
| 39 | call setline(1, ['one', 'two', 'three']) |
| 40 | call cursor(1,2) |
| 41 | set noshowmode |
| 42 | set tw=0 |
| 43 | call feedkeys("\<c-v>jjlIa\<c-\>\<c-o>:set tw=88\<cr>\<esc>", 'tx') |
| 44 | call assert_equal(['oane', 'tawo', 'tahree'], getline(1, 3)) |
| 45 | call assert_equal(88, &tw) |
| 46 | set tw& |
| 47 | bw! |
| 48 | endfu |
Bram Moolenaar | 84b2a38 | 2017-02-17 11:40:00 +0100 | [diff] [blame] | 49 | |
| 50 | func Test_Visual_vapo() |
| 51 | new |
| 52 | normal oxx |
| 53 | normal vapo |
| 54 | bwipe! |
| 55 | endfunc |
Bram Moolenaar | 46522af | 2017-02-18 23:12:01 +0100 | [diff] [blame] | 56 | |
| 57 | func Test_Visual_inner_quote() |
| 58 | new |
| 59 | normal oxX |
| 60 | normal vki' |
| 61 | bwipe! |
| 62 | endfunc |
Bram Moolenaar | 75373f3 | 2017-08-07 22:02:30 +0200 | [diff] [blame] | 63 | |
| 64 | " Test for Visual mode not being reset causing E315 error. |
| 65 | func TriggerTheProblem() |
| 66 | " At this point there is no visual selection because :call reset it. |
| 67 | " Let's restore the selection: |
| 68 | normal gv |
| 69 | '<,'>del _ |
| 70 | try |
| 71 | exe "normal \<Esc>" |
| 72 | catch /^Vim\%((\a\+)\)\=:E315/ |
| 73 | echom 'Snap! E315 error!' |
| 74 | let g:msg='Snap! E315 error!' |
| 75 | endtry |
| 76 | endfunc |
| 77 | |
| 78 | func Test_visual_mode_reset() |
| 79 | set belloff=all |
| 80 | enew |
| 81 | let g:msg="Everything's fine." |
| 82 | enew |
| 83 | setl buftype=nofile |
| 84 | call append(line('$'), 'Delete this line.') |
| 85 | |
| 86 | " NOTE: this has to be done by a call to a function because executing :del |
| 87 | " the ex-way will require the colon operator which resets the visual mode |
| 88 | " thus preventing the problem: |
| 89 | exe "normal! GV:call TriggerTheProblem()\<CR>" |
| 90 | call assert_equal("Everything's fine.", g:msg) |
| 91 | |
| 92 | set belloff& |
| 93 | endfunc |