Mirror of the Vim source from https://github.com/vim/vim
Révision | be81baeb69f8abd67575ea4164866bf9ab8db96c (tree) |
---|---|
l'heure | 2020-01-24 05:00:03 |
Auteur | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
patch 8.2.0147: block Visual mode operators not correct when 'linebreak' set
Commit: https://github.com/vim/vim/commit/03c3bd9fd094c1aede2e8fe3ad8fd25b9f033053
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 23 20:58:09 2020 +0100
@@ -2744,7 +2744,12 @@ | ||
2744 | 2744 | char_u *line; |
2745 | 2745 | char_u *prev_pstart; |
2746 | 2746 | char_u *prev_pend; |
2747 | - | |
2747 | +#ifdef FEAT_LINEBREAK | |
2748 | + int lbr_saved = curwin->w_p_lbr; | |
2749 | + | |
2750 | + // Avoid a problem with unwanted linebreaks in block mode. | |
2751 | + curwin->w_p_lbr = FALSE; | |
2752 | +#endif | |
2748 | 2753 | bdp->startspaces = 0; |
2749 | 2754 | bdp->endspaces = 0; |
2750 | 2755 | bdp->textlen = 0; |
@@ -2863,6 +2868,9 @@ | ||
2863 | 2868 | } |
2864 | 2869 | bdp->textcol = (colnr_T) (pstart - line); |
2865 | 2870 | bdp->textstart = pstart; |
2871 | +#ifdef FEAT_LINEBREAK | |
2872 | + curwin->w_p_lbr = lbr_saved; | |
2873 | +#endif | |
2866 | 2874 | } |
2867 | 2875 | |
2868 | 2876 | /* |
@@ -4556,11 +4564,7 @@ | ||
4556 | 4564 | #ifdef FEAT_LINEBREAK |
4557 | 4565 | // Restore linebreak, so that when the user edits it looks as |
4558 | 4566 | // before. |
4559 | - if (curwin->w_p_lbr != lbr_saved) | |
4560 | - { | |
4561 | - curwin->w_p_lbr = lbr_saved; | |
4562 | - get_op_vcol(oap, redo_VIsual_mode, FALSE); | |
4563 | - } | |
4567 | + curwin->w_p_lbr = lbr_saved; | |
4564 | 4568 | #endif |
4565 | 4569 | // Reset finish_op now, don't want it set inside edit(). |
4566 | 4570 | finish_op = FALSE; |
@@ -4663,11 +4667,7 @@ | ||
4663 | 4667 | #ifdef FEAT_LINEBREAK |
4664 | 4668 | // Restore linebreak, so that when the user edits it looks as |
4665 | 4669 | // before. |
4666 | - if (curwin->w_p_lbr != lbr_saved) | |
4667 | - { | |
4668 | - curwin->w_p_lbr = lbr_saved; | |
4669 | - get_op_vcol(oap, redo_VIsual_mode, FALSE); | |
4670 | - } | |
4670 | + curwin->w_p_lbr = lbr_saved; | |
4671 | 4671 | #endif |
4672 | 4672 | op_insert(oap, cap->count1); |
4673 | 4673 | #ifdef FEAT_LINEBREAK |
@@ -4698,11 +4698,7 @@ | ||
4698 | 4698 | #ifdef FEAT_LINEBREAK |
4699 | 4699 | // Restore linebreak, so that when the user edits it looks as |
4700 | 4700 | // before. |
4701 | - if (curwin->w_p_lbr != lbr_saved) | |
4702 | - { | |
4703 | - curwin->w_p_lbr = lbr_saved; | |
4704 | - get_op_vcol(oap, redo_VIsual_mode, FALSE); | |
4705 | - } | |
4701 | + curwin->w_p_lbr = lbr_saved; | |
4706 | 4702 | #endif |
4707 | 4703 | op_replace(oap, cap->nchar); |
4708 | 4704 | } |
@@ -100,6 +100,37 @@ | ||
100 | 100 | call s:close_windows() |
101 | 101 | endfunc |
102 | 102 | |
103 | +func Test_linebreak_with_visual_operations() | |
104 | + call s:test_windows() | |
105 | + let line = '1234567890 2234567890 3234567890' | |
106 | + call setline(1, line) | |
107 | + | |
108 | + " yank | |
109 | + exec "norm! ^w\<C-V>ey" | |
110 | + call assert_equal('2234567890', @@) | |
111 | + exec "norm! w\<C-V>ey" | |
112 | + call assert_equal('3234567890', @@) | |
113 | + | |
114 | + " increment / decrement | |
115 | + exec "norm! ^w\<C-V>\<C-A>w\<C-V>\<C-X>" | |
116 | + call assert_equal('1234567890 3234567890 2234567890', getline(1)) | |
117 | + | |
118 | + " replace | |
119 | + exec "norm! ^w\<C-V>3lraw\<C-V>3lrb" | |
120 | + call assert_equal('1234567890 aaaa567890 bbbb567890', getline(1)) | |
121 | + | |
122 | + " tilde | |
123 | + exec "norm! ^w\<C-V>2l~w\<C-V>2l~" | |
124 | + call assert_equal('1234567890 AAAa567890 BBBb567890', getline(1)) | |
125 | + | |
126 | + " delete and insert | |
127 | + exec "norm! ^w\<C-V>3lc2345\<Esc>w\<C-V>3lc3456\<Esc>" | |
128 | + call assert_equal('1234567890 2345567890 3456567890', getline(1)) | |
129 | + call assert_equal('BBBb', @@) | |
130 | + | |
131 | + call s:close_windows() | |
132 | +endfunc | |
133 | + | |
103 | 134 | func Test_virtual_block() |
104 | 135 | call s:test_windows('setl sbr=+') |
105 | 136 | call setline(1, [ |
@@ -743,6 +743,8 @@ | ||
743 | 743 | static int included_patches[] = |
744 | 744 | { /* Add new patch number below this line */ |
745 | 745 | /**/ |
746 | + 147, | |
747 | +/**/ | |
746 | 748 | 146, |
747 | 749 | /**/ |
748 | 750 | 145, |