diff --git a/7.4.753 b/7.4.753 new file mode 100644 index 0000000..1af52be --- /dev/null +++ b/7.4.753 @@ -0,0 +1,342 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.4.753 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.4.753 +Problem: Appending in Visual mode with 'linebreak' set does not work + properly. Also when 'selection' is "exclusive". (Ingo Karkat) +Solution: Recalculate virtual columns. (Christian Brabandt) +Files: src/normal.c, src/testdir/test_listlbr.in, + src/testdir/test_listlbr.ok, src/testdir/test_listlbr_utf8.in, + src/testdir/test_listlbr_utf8.ok + + +*** ../vim-7.4.752/src/normal.c 2015-06-10 12:16:41.926648740 +0200 +--- src/normal.c 2015-06-25 12:47:07.989550746 +0200 +*************** +*** 174,179 **** +--- 174,180 ---- + #ifdef FEAT_AUTOCMD + static void nv_cursorhold __ARGS((cmdarg_T *cap)); + #endif ++ static void get_op_vcol __ARGS((oparg_T *oap, colnr_T col, int initial)); + + static char *e_noident = N_("E349: No identifier under cursor"); + +*************** +*** 1418,1423 **** +--- 1419,1426 ---- + { + #ifdef FEAT_LINEBREAK + /* Avoid a problem with unwanted linebreaks in block mode. */ ++ if (curwin->w_p_lbr) ++ curwin->w_valid &= ~VALID_VIRTCOL; + curwin->w_p_lbr = FALSE; + #endif + oap->is_VIsual = VIsual_active; +*************** +*** 1631,1691 **** + + if (VIsual_active || redo_VIsual_busy) + { +! if (VIsual_mode == Ctrl_V) /* block mode */ +! { +! colnr_T start, end; +! +! oap->block_mode = TRUE; +! +! getvvcol(curwin, &(oap->start), +! &oap->start_vcol, NULL, &oap->end_vcol); +! if (!redo_VIsual_busy) +! { +! getvvcol(curwin, &(oap->end), &start, NULL, &end); +! +! if (start < oap->start_vcol) +! oap->start_vcol = start; +! if (end > oap->end_vcol) +! { +! if (*p_sel == 'e' && start >= 1 +! && start - 1 >= oap->end_vcol) +! oap->end_vcol = start - 1; +! else +! oap->end_vcol = end; +! } +! } +! +! /* if '$' was used, get oap->end_vcol from longest line */ +! if (curwin->w_curswant == MAXCOL) +! { +! curwin->w_cursor.col = MAXCOL; +! oap->end_vcol = 0; +! for (curwin->w_cursor.lnum = oap->start.lnum; +! curwin->w_cursor.lnum <= oap->end.lnum; +! ++curwin->w_cursor.lnum) +! { +! getvvcol(curwin, &curwin->w_cursor, NULL, NULL, &end); +! if (end > oap->end_vcol) +! oap->end_vcol = end; +! } +! } +! else if (redo_VIsual_busy) +! oap->end_vcol = oap->start_vcol + redo_VIsual_vcol - 1; +! /* +! * Correct oap->end.col and oap->start.col to be the +! * upper-left and lower-right corner of the block area. +! * +! * (Actually, this does convert column positions into character +! * positions) +! */ +! curwin->w_cursor.lnum = oap->end.lnum; +! coladvance(oap->end_vcol); +! oap->end = curwin->w_cursor; +! +! curwin->w_cursor = oap->start; +! coladvance(oap->start_vcol); +! oap->start = curwin->w_cursor; +! } + + if (!redo_VIsual_busy && !gui_yank) + { +--- 1634,1640 ---- + + if (VIsual_active || redo_VIsual_busy) + { +! get_op_vcol(oap, redo_VIsual_vcol, TRUE); + + if (!redo_VIsual_busy && !gui_yank) + { +*************** +*** 1982,1988 **** + #ifdef FEAT_LINEBREAK + /* Restore linebreak, so that when the user edits it looks as + * before. */ +! curwin->w_p_lbr = lbr_saved; + #endif + /* Reset finish_op now, don't want it set inside edit(). */ + finish_op = FALSE; +--- 1931,1941 ---- + #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); +! } + #endif + /* Reset finish_op now, don't want it set inside edit(). */ + finish_op = FALSE; +*************** +*** 2082,2088 **** + #ifdef FEAT_LINEBREAK + /* Restore linebreak, so that when the user edits it looks as + * before. */ +! curwin->w_p_lbr = lbr_saved; + #endif + op_insert(oap, cap->count1); + #ifdef FEAT_LINEBREAK +--- 2035,2045 ---- + #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); +! } + #endif + op_insert(oap, cap->count1); + #ifdef FEAT_LINEBREAK +*************** +*** 2114,2124 **** + #ifdef FEAT_VISUALEXTRA + else + { +! #ifdef FEAT_LINEBREAK + /* Restore linebreak, so that when the user edits it looks as + * before. */ +! curwin->w_p_lbr = lbr_saved; +! #endif + op_replace(oap, cap->nchar); + } + #endif +--- 2071,2085 ---- + #ifdef FEAT_VISUALEXTRA + else + { +! # 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); +! } +! # endif + op_replace(oap, cap->nchar); + } + #endif +*************** +*** 9542,9544 **** +--- 9503,9572 ---- + cap->retval |= CA_COMMAND_BUSY; /* don't call edit() now */ + } + #endif ++ ++ /* ++ * calculate start/end virtual columns for operating in block mode ++ */ ++ static void ++ get_op_vcol(oap, redo_VIsual_vcol, initial) ++ oparg_T *oap; ++ colnr_T redo_VIsual_vcol; ++ int initial; /* when true: adjust position for 'selectmode' */ ++ { ++ colnr_T start, end; ++ ++ if (VIsual_mode != Ctrl_V) ++ return; ++ ++ oap->block_mode = TRUE; ++ ++ #ifdef FEAT_MBYTE ++ /* prevent from moving onto a trail byte */ ++ if (has_mbyte) ++ mb_adjustpos(curwin->w_buffer, &oap->end); ++ #endif ++ ++ getvvcol(curwin, &(oap->start), &oap->start_vcol, NULL, &oap->end_vcol); ++ getvvcol(curwin, &(oap->end), &start, NULL, &end); ++ ++ if (start < oap->start_vcol) ++ oap->start_vcol = start; ++ if (end > oap->end_vcol) ++ { ++ if (initial && *p_sel == 'e' && start >= 1 ++ && start - 1 >= oap->end_vcol) ++ oap->end_vcol = start - 1; ++ else ++ oap->end_vcol = end; ++ } ++ /* if '$' was used, get oap->end_vcol from longest line */ ++ if (curwin->w_curswant == MAXCOL) ++ { ++ curwin->w_cursor.col = MAXCOL; ++ oap->end_vcol = 0; ++ for (curwin->w_cursor.lnum = oap->start.lnum; ++ curwin->w_cursor.lnum <= oap->end.lnum; ++ ++curwin->w_cursor.lnum) ++ { ++ getvvcol(curwin, &curwin->w_cursor, NULL, NULL, &end); ++ if (end > oap->end_vcol) ++ oap->end_vcol = end; ++ } ++ } ++ else if (redo_VIsual_busy) ++ oap->end_vcol = oap->start_vcol + redo_VIsual_vcol - 1; ++ /* ++ * Correct oap->end.col and oap->start.col to be the ++ * upper-left and lower-right corner of the block area. ++ * ++ * (Actually, this does convert column positions into character ++ * positions) ++ */ ++ curwin->w_cursor.lnum = oap->end.lnum; ++ coladvance(oap->end_vcol); ++ oap->end = curwin->w_cursor; ++ ++ curwin->w_cursor = oap->start; ++ coladvance(oap->start_vcol); ++ oap->start = curwin->w_cursor; ++ } +*** ../vim-7.4.752/src/testdir/test_listlbr.in 2014-10-09 13:22:41.804886993 +0200 +--- src/testdir/test_listlbr.in 2015-06-25 12:45:05.854814853 +0200 +*************** +*** 59,69 **** +--- 59,79 ---- + :set cpo&vim linebreak + :let g:test ="Test 6: set linebreak with visual block mode" + :let line="REMOVE: this not" ++ :$put =g:test + :$put =line + :let line="REMOVE: aaaaaaaaaaaaa" + :$put =line + :1/^REMOVE: + 0jf x:$put ++ :set cpo&vim linebreak ++ :let g:test ="Test 7: set linebreak with visual block mode and v_b_A" ++ :$put =g:test ++ Golong line: 40afoobar aTARGET at end ++ :exe "norm! $3B\eAx\" ++ :set cpo&vim linebreak sbr= ++ :let g:test ="Test 8: set linebreak with visual char mode and changing block" ++ :$put =g:test ++ Go1111-1111-1111-11-1111-1111-11110f-lv3lc2222bgj. + :%w! test.out + :qa! + ENDTEST +*** ../vim-7.4.752/src/testdir/test_listlbr.ok 2014-10-09 13:22:41.808886993 +0200 +--- src/testdir/test_listlbr.ok 2015-06-25 12:45:05.854814853 +0200 +*************** +*** 32,38 **** +--- 32,43 ---- + ~ + ~ + ~ ++ Test 6: set linebreak with visual block mode + this not + aaaaaaaaaaaaa + REMOVE: + REMOVE: ++ Test 7: set linebreak with visual block mode and v_b_A ++ long line: foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar TARGETx at end ++ Test 8: set linebreak with visual char mode and changing block ++ 1111-2222-1111-11-1111-2222-1111 +*** ../vim-7.4.752/src/testdir/test_listlbr_utf8.in 2015-02-17 17:26:04.561123749 +0100 +--- src/testdir/test_listlbr_utf8.in 2015-06-25 13:28:00.739775396 +0200 +*************** +*** 91,96 **** +--- 91,101 ---- + :else + : call append('$', "Not all attributes are different") + :endif ++ :set cpo&vim linebreak selection=exclusive ++ :let g:test ="Test 8: set linebreak with visual block mode and v_b_A and selection=exclusive and multibyte char" ++ :$put =g:test ++ Golong line: 40afoobar aTARGETÃ' at end ++ :exe "norm! $3B\eAx\" + :%w! test.out + :qa! + ENDTEST +*** ../vim-7.4.752/src/testdir/test_listlbr_utf8.ok 2015-02-17 17:26:04.561123749 +0100 +--- src/testdir/test_listlbr_utf8.ok 2015-06-25 13:28:20.459568969 +0200 +*************** +*** 44,46 **** +--- 44,48 ---- + /* and some more */ + ScreenAttributes for test6: + Attribut 0 and 1 and 3 and 5 are different! ++ Test 8: set linebreak with visual block mode and v_b_A and selection=exclusive and multibyte char ++ long line: foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar TARGETÃx' at end +*** ../vim-7.4.752/src/version.c 2015-06-21 14:21:54.477599972 +0200 +--- src/version.c 2015-06-25 12:44:49.274986455 +0200 +*************** +*** 743,744 **** +--- 743,746 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 753, + /**/ + +-- +Drink wet cement and get really stoned. + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org ///