Mercurial > vim
comparison src/testdir/test_increment.vim @ 7574:b872724c37db v7.4.1087
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 10 22:13:02 2016 +0100
patch 7.4.1087
Problem: CTRL-A and CTRL-X do not work properly with blockwise visual
selection if there is a mix of Tab and spaces.
Solution: Add OP_NR_ADD and OP_NR_SUB. (Hirohito Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 10 Jan 2016 22:15:04 +0100 |
parents | 5274513d3f54 |
children | fdae4c496775 |
comparison
equal
deleted
inserted
replaced
7573:4c8a7f265023 | 7574:b872724c37db |
---|---|
131 func Test_visual_increment_04() | 131 func Test_visual_increment_04() |
132 call setline(1, ["foobar-10"]) | 132 call setline(1, ["foobar-10"]) |
133 exec "norm! vf-\<C-A>" | 133 exec "norm! vf-\<C-A>" |
134 call assert_equal(["foobar-10"], getline(1, '$')) | 134 call assert_equal(["foobar-10"], getline(1, '$')) |
135 " NOTE: I think this is correct behavior... | 135 " NOTE: I think this is correct behavior... |
136 "call assert_equal([0, 1, 1, 0], getpos('.')) | 136 call assert_equal([0, 1, 1, 0], getpos('.')) |
137 endfunc | 137 endfunc |
138 | 138 |
139 " 5) g<Ctrl-A> on letter | 139 " 5) g<Ctrl-A> on letter |
140 " Test: | 140 " Test: |
141 " a | 141 " a |
574 call assert_equal([0, 1, 7, 0], getpos('.')) | 574 call assert_equal([0, 1, 7, 0], getpos('.')) |
575 set norightleft | 575 set norightleft |
576 endif | 576 endif |
577 endfunc | 577 endfunc |
578 | 578 |
579 " 28) block-wise increment and dot-repeat | 579 " Tab code and linewise-visual inc/dec |
580 func Test_visual_increment_28() | |
581 call setline(1, ["x\<TAB>10", "\<TAB>-1"]) | |
582 exec "norm! Vj\<C-A>" | |
583 call assert_equal(["x\<TAB>11", "\<TAB>0"], getline(1, '$')) | |
584 call assert_equal([0, 1, 1, 0], getpos('.')) | |
585 | |
586 call setline(1, ["x\<TAB>10", "\<TAB>-1"]) | |
587 exec "norm! ggVj\<C-X>" | |
588 call assert_equal(["x\<TAB>9", "\<TAB>-2"], getline(1, '$')) | |
589 call assert_equal([0, 1, 1, 0], getpos('.')) | |
590 endfunc | |
591 | |
592 " Tab code and linewise-visual inc/dec with 'nrformats'+=alpha | |
593 func Test_visual_increment_29() | |
594 set nrformats+=alpha | |
595 call setline(1, ["x\<TAB>10", "\<TAB>-1"]) | |
596 exec "norm! Vj\<C-A>" | |
597 call assert_equal(["y\<TAB>10", "\<TAB>0"], getline(1, '$')) | |
598 call assert_equal([0, 1, 1, 0], getpos('.')) | |
599 | |
600 call setline(1, ["x\<TAB>10", "\<TAB>-1"]) | |
601 exec "norm! ggVj\<C-X>" | |
602 call assert_equal(["w\<TAB>10", "\<TAB>-2"], getline(1, '$')) | |
603 call assert_equal([0, 1, 1, 0], getpos('.')) | |
604 endfunc | |
605 | |
606 " Tab code and character-visual inc/dec | |
607 func Test_visual_increment_30() | |
608 call setline(1, ["x\<TAB>10", "\<TAB>-1"]) | |
609 exec "norm! f1vjf1\<C-A>" | |
610 call assert_equal(["x\<TAB>11", "\<TAB>0"], getline(1, '$')) | |
611 call assert_equal([0, 1, 3, 0], getpos('.')) | |
612 | |
613 call setline(1, ["x\<TAB>10", "\<TAB>-1"]) | |
614 exec "norm! ggf1vjf1\<C-X>" | |
615 call assert_equal(["x\<TAB>9", "\<TAB>-2"], getline(1, '$')) | |
616 call assert_equal([0, 1, 3, 0], getpos('.')) | |
617 endfunc | |
618 | |
619 " Tab code and blockwise-visual inc/dec | |
620 func Test_visual_increment_31() | |
621 call setline(1, ["x\<TAB>10", "\<TAB>-1"]) | |
622 exec "norm! f1\<C-V>jl\<C-A>" | |
623 call assert_equal(["x\<TAB>11", "\<TAB>0"], getline(1, '$')) | |
624 call assert_equal([0, 1, 3, 0], getpos('.')) | |
625 | |
626 call setline(1, ["x\<TAB>10", "\<TAB>-1"]) | |
627 exec "norm! ggf1\<C-V>jl\<C-X>" | |
628 call assert_equal(["x\<TAB>9", "\<TAB>-2"], getline(1, '$')) | |
629 call assert_equal([0, 1, 3, 0], getpos('.')) | |
630 endfunc | |
631 | |
632 " Tab code and blockwise-visual decrement with 'linebreak' and 'showbreak' | |
633 func Test_visual_increment_32() | |
634 28vnew dummy_31 | |
635 set linebreak showbreak=+ | |
636 call setline(1, ["x\<TAB>\<TAB>\<TAB>10", "\<TAB>\<TAB>\<TAB>\<TAB>-1"]) | |
637 exec "norm! ggf0\<C-V>jg_\<C-X>" | |
638 call assert_equal(["x\<TAB>\<TAB>\<TAB>1-1", "\<TAB>\<TAB>\<TAB>\<TAB>-2"], getline(1, '$')) | |
639 call assert_equal([0, 1, 6, 0], getpos('.')) | |
640 bwipe! | |
641 endfunc | |
642 | |
643 " Tab code and blockwise-visual increment with $ | |
644 func Test_visual_increment_33() | |
645 call setline(1, ["\<TAB>123", "456"]) | |
646 exec "norm! gg0\<C-V>j$\<C-A>" | |
647 call assert_equal(["\<TAB>124", "457"], getline(1, '$')) | |
648 call assert_equal([0, 1, 1, 0], getpos('.')) | |
649 endfunc | |
650 | |
651 " Tab code and blockwise-visual increment and redo | |
652 func Test_visual_increment_34() | |
653 call setline(1, ["\<TAB>123", " 456789"]) | |
654 exec "norm! gg0\<C-V>j\<C-A>" | |
655 call assert_equal(["\<TAB>123", " 457789"], getline(1, '$')) | |
656 call assert_equal([0, 1, 1, 0], getpos('.')) | |
657 | |
658 exec "norm! .." | |
659 call assert_equal(["\<TAB>123", " 459789"], getline(1, '$')) | |
660 call assert_equal([0, 1, 1, 0], getpos('.')) | |
661 endfunc | |
662 | |
663 " Tab code, spaces and character-visual increment and redo | |
664 func Test_visual_increment_35() | |
665 call setline(1, ["\<TAB>123", " 123", "\<TAB>123", "\<TAB>123"]) | |
666 exec "norm! ggvjf3\<C-A>..." | |
667 call assert_equal(["\<TAB>127", " 127", "\<TAB>123", "\<TAB>123"], getline(1, '$')) | |
668 call assert_equal([0, 1, 2, 0], getpos('.')) | |
669 endfunc | |
670 | |
671 " Tab code, spaces and blockwise-visual increment and redo | |
672 func Test_visual_increment_36() | |
673 call setline(1, [" 123", "\<TAB>456789"]) | |
674 exec "norm! G0\<C-V>kl\<C-A>" | |
675 call assert_equal([" 123", "\<TAB>556789"], getline(1, '$')) | |
676 call assert_equal([0, 1, 1, 0], getpos('.')) | |
677 | |
678 exec "norm! ..." | |
679 call assert_equal([" 123", "\<TAB>856789"], getline(1, '$')) | |
680 call assert_equal([0, 1, 1, 0], getpos('.')) | |
681 endfunc | |
682 | |
683 " block-wise increment and dot-repeat | |
580 " Text: | 684 " Text: |
581 " 1 23 | 685 " 1 23 |
582 " 4 56 | 686 " 4 56 |
583 " | 687 " |
584 " Expected: | 688 " Expected: |
585 " 1) f2 Ctrl-V jl <ctrl-a>, repeat twice afterwards with . | 689 " 1) f2 Ctrl-V jl <ctrl-a>, repeat twice afterwards with . |
586 " 1 26 | 690 " 1 26 |
587 " 4 59 | 691 " 4 59 |
588 " | 692 " |
589 " Try with and without indent. | 693 " Try with and without indent. |
590 func Test_visual_increment_28() | 694 func Test_visual_increment_37() |
591 call setline(1, [" 1 23", " 4 56"]) | 695 call setline(1, [" 1 23", " 4 56"]) |
592 exec "norm! ggf2\<C-V>jl\<C-A>.." | 696 exec "norm! ggf2\<C-V>jl\<C-A>.." |
593 call assert_equal([" 1 26", " 4 59"], getline(1, 2)) | 697 call assert_equal([" 1 26", " 4 59"], getline(1, 2)) |
594 | 698 |
595 call setline(1, ["1 23", "4 56"]) | 699 call setline(1, ["1 23", "4 56"]) |