# HG changeset patch # User Bram Moolenaar # Date 1579809603 -3600 # Node ID be81baeb69f8abd67575ea4164866bf9ab8db96c # Parent eded52b4666b9103be427dffdd4aeb867bea1b37 patch 8.2.0147: block Visual mode operators not correct when 'linebreak' set Commit: https://github.com/vim/vim/commit/03c3bd9fd094c1aede2e8fe3ad8fd25b9f033053 Author: Bram Moolenaar Date: Thu Jan 23 20:58:09 2020 +0100 patch 8.2.0147: block Visual mode operators not correct when 'linebreak' set Problem: Block Visual mode operators not correct when 'linebreak' set. Solution: Set w_p_lbr to lbr_saved more often. (Ken Takata, closes https://github.com/vim/vim/issues/5524) diff --git a/src/ops.c b/src/ops.c --- a/src/ops.c +++ b/src/ops.c @@ -2744,7 +2744,12 @@ block_prep( char_u *line; char_u *prev_pstart; char_u *prev_pend; - +#ifdef FEAT_LINEBREAK + int lbr_saved = curwin->w_p_lbr; + + // Avoid a problem with unwanted linebreaks in block mode. + curwin->w_p_lbr = FALSE; +#endif bdp->startspaces = 0; bdp->endspaces = 0; bdp->textlen = 0; @@ -2863,6 +2868,9 @@ block_prep( } bdp->textcol = (colnr_T) (pstart - line); bdp->textstart = pstart; +#ifdef FEAT_LINEBREAK + curwin->w_p_lbr = lbr_saved; +#endif } /* @@ -4556,11 +4564,7 @@ do_pending_operator(cmdarg_T *cap, int o #ifdef FEAT_LINEBREAK // Restore linebreak, so that when the user edits it looks as // before. - if (curwin->w_p_lbr != lbr_saved) - { - curwin->w_p_lbr = lbr_saved; - get_op_vcol(oap, redo_VIsual_mode, FALSE); - } + curwin->w_p_lbr = lbr_saved; #endif // Reset finish_op now, don't want it set inside edit(). finish_op = FALSE; @@ -4663,11 +4667,7 @@ do_pending_operator(cmdarg_T *cap, int o #ifdef FEAT_LINEBREAK // Restore linebreak, so that when the user edits it looks as // before. - if (curwin->w_p_lbr != lbr_saved) - { - curwin->w_p_lbr = lbr_saved; - get_op_vcol(oap, redo_VIsual_mode, FALSE); - } + curwin->w_p_lbr = lbr_saved; #endif op_insert(oap, cap->count1); #ifdef FEAT_LINEBREAK @@ -4698,11 +4698,7 @@ do_pending_operator(cmdarg_T *cap, int o #ifdef FEAT_LINEBREAK // Restore linebreak, so that when the user edits it looks as // before. - if (curwin->w_p_lbr != lbr_saved) - { - curwin->w_p_lbr = lbr_saved; - get_op_vcol(oap, redo_VIsual_mode, FALSE); - } + curwin->w_p_lbr = lbr_saved; #endif op_replace(oap, cap->nchar); } diff --git a/src/testdir/test_listlbr.vim b/src/testdir/test_listlbr.vim --- a/src/testdir/test_listlbr.vim +++ b/src/testdir/test_listlbr.vim @@ -100,6 +100,37 @@ func Test_linebreak_with_conceal() call s:close_windows() endfunc +func Test_linebreak_with_visual_operations() + call s:test_windows() + let line = '1234567890 2234567890 3234567890' + call setline(1, line) + + " yank + exec "norm! ^w\ey" + call assert_equal('2234567890', @@) + exec "norm! w\ey" + call assert_equal('3234567890', @@) + + " increment / decrement + exec "norm! ^w\\w\\" + call assert_equal('1234567890 3234567890 2234567890', getline(1)) + + " replace + exec "norm! ^w\3lraw\3lrb" + call assert_equal('1234567890 aaaa567890 bbbb567890', getline(1)) + + " tilde + exec "norm! ^w\2l~w\2l~" + call assert_equal('1234567890 AAAa567890 BBBb567890', getline(1)) + + " delete and insert + exec "norm! ^w\3lc2345\w\3lc3456\" + call assert_equal('1234567890 2345567890 3456567890', getline(1)) + call assert_equal('BBBb', @@) + + call s:close_windows() +endfunc + func Test_virtual_block() call s:test_windows('setl sbr=+') call setline(1, [ diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -743,6 +743,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 147, +/**/ 146, /**/ 145,