To: vim-dev@vim.org Subject: Patch 6.1.014 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.014 Problem: An operator like "r" used in Visual block mode doesn't use 'virtualedit' when it's set to "block". Solution: Check for 'virtualedit' being active in Visual block mode when the operator was started. Files: src/ex_docmd.c, src/globals.h, src/misc2.c, src/normal.c, src/ops.c, src/undo.c *** ../vim61.013/src/ex_docmd.c Mon Apr 8 22:11:31 2002 --- src/ex_docmd.c Tue Apr 9 22:50:00 2002 *************** *** 6242,6247 **** --- 6242,6250 ---- oa.end.lnum = eap->line2; oa.line_count = eap->line2 - eap->line1 + 1; oa.motion_type = MLINE; + #ifdef FEAT_VIRTUALEDIT + virtual_op = FALSE; + #endif if (eap->cmdidx != CMD_yank) /* position cursor for undo */ { setpcmark(); *************** *** 6273,6278 **** --- 6276,6284 ---- op_shift(&oa, FALSE, eap->amount); break; } + #ifdef FEAT_VIRTUALEDIT + virtual_op = MAYBE; + #endif } /* *** ../vim61.013/src/globals.h Sun Mar 17 14:10:52 2002 --- src/globals.h Tue Apr 9 22:47:26 2002 *************** *** 1013,1018 **** --- 1013,1024 ---- ; #endif + #ifdef FEAT_VIRTUALEDIT + /* Set to TRUE when an operator is being executed with virtual editing, MAYBE + * when no operator is being executed, FALSE otherwise. */ + EXTERN int virtual_op INIT(= MAYBE); + #endif + #ifdef FEAT_SYN_HL /* Display tick, incremented for each call to update_screen() */ EXTERN disptick_T display_tick INIT(= 0); *** ../vim61.013/src/misc2.c Sun Mar 10 14:39:46 2002 --- src/misc2.c Tue Apr 9 22:13:46 2002 *************** *** 25,30 **** --- 25,35 ---- int virtual_active() { + /* While an operator is being executed we return "virtual_op", because + * VIsual_active has already been reset, thus we can't check for "block" + * being used. */ + if (virtual_op != MAYBE) + return virtual_op; return (ve_flags == VE_ALL # ifdef FEAT_VISUAL || ((ve_flags & VE_BLOCK) && VIsual_active && VIsual_mode == Ctrl_V) *** ../vim61.013/src/normal.c Wed Apr 3 22:33:54 2002 --- src/normal.c Tue Apr 9 22:35:26 2002 *************** *** 1434,1439 **** --- 1434,1444 ---- oap->line_count = oap->end.lnum - oap->start.lnum + 1; + #ifdef FEAT_VIRTUALEDIT + /* Set "virtual_op" before resetting VIsual_active. */ + virtual_op = virtual_active(); + #endif + #ifdef FEAT_VISUAL if (VIsual_active || redo_VIsual_busy) { *************** *** 1551,1557 **** oap->motion_type = MCHAR; if (VIsual_mode != Ctrl_V && *ml_get_pos(&(oap->end)) == NUL # ifdef FEAT_VIRTUALEDIT ! && (include_line_break || !virtual_active()) # endif ) { --- 1556,1562 ---- oap->motion_type = MCHAR; if (VIsual_mode != Ctrl_V && *ml_get_pos(&(oap->end)) == NUL # ifdef FEAT_VIRTUALEDIT ! && (include_line_break || !virtual_op) # endif ) { *************** *** 1631,1638 **** && gchar_pos(&oap->end) == NUL)) && equal(oap->start, oap->end) #ifdef FEAT_VIRTUALEDIT ! && !(virtual_active() ! && oap->start.coladd != oap->end.coladd) #endif ); /* --- 1636,1642 ---- && gchar_pos(&oap->end) == NUL)) && equal(oap->start, oap->end) #ifdef FEAT_VIRTUALEDIT ! && !(virtual_op && oap->start.coladd != oap->end.coladd) #endif ); /* *************** *** 1879,1884 **** --- 1883,1891 ---- default: clearopbeep(oap); } + #ifdef FEAT_VIRTUALEDIT + virtual_op = MAYBE; + #endif if (!gui_yank) { /* *** ../vim61.013/src/ops.c Wed Apr 3 22:33:54 2002 --- src/ops.c Tue Apr 9 22:53:15 2002 *************** *** 1641,1647 **** else { #ifdef FEAT_VIRTUALEDIT ! if (virtual_active()) { int endcol = 0; --- 1641,1647 ---- else { #ifdef FEAT_VIRTUALEDIT ! if (virtual_op) { int endcol = 0; *************** *** 1696,1702 **** n = oap->end.col - oap->start.col + 1 - !oap->inclusive; #ifdef FEAT_VIRTUALEDIT ! if (virtual_active()) { /* fix up things for virtualedit-delete: * break the tabs which are going to get in our way --- 1696,1702 ---- n = oap->end.col - oap->start.col + 1 - !oap->inclusive; #ifdef FEAT_VIRTUALEDIT ! if (virtual_op) { /* fix up things for virtualedit-delete: * break the tabs which are going to get in our way *************** *** 1717,1723 **** curwin->w_cursor.coladd = 0; } #endif ! (void)del_bytes((long)n, restart_edit == NUL && !virtual_active()); } else /* delete characters between lines */ { --- 1717,1723 ---- curwin->w_cursor.coladd = 0; } #endif ! (void)del_bytes((long)n, restart_edit == NUL && !virtual_op); } else /* delete characters between lines */ { *************** *** 1737,1743 **** /* delete from start of line until op_end */ curwin->w_cursor.col = 0; (void)del_bytes((long)(oap->end.col + 1 - !oap->inclusive), ! restart_edit == NUL && !virtual_active()); curwin->w_cursor = curpos; /* restore curwin->w_cursor */ (void)do_join(FALSE); --- 1737,1743 ---- /* delete from start of line until op_end */ curwin->w_cursor.col = 0; (void)del_bytes((long)(oap->end.col + 1 - !oap->inclusive), ! restart_edit == NUL && !virtual_op); curwin->w_cursor = curpos; /* restore curwin->w_cursor */ (void)do_join(FALSE); *************** *** 1846,1852 **** for ( ; curwin->w_cursor.lnum <= oap->end.lnum; ++curwin->w_cursor.lnum) { block_prep(oap, &bd, curwin->w_cursor.lnum, TRUE); ! if (bd.textlen == 0 && !virtual_active()) /* nothing to delete */ continue; /* n == number of extra chars required --- 1846,1852 ---- for ( ; curwin->w_cursor.lnum <= oap->end.lnum; ++curwin->w_cursor.lnum) { block_prep(oap, &bd, curwin->w_cursor.lnum, TRUE); ! if (bd.textlen == 0 && !virtual_op) /* nothing to delete */ continue; /* n == number of extra chars required *************** *** 1856,1862 **** #ifdef FEAT_VIRTUALEDIT /* If the range starts in virtual space, count the initial * coladd offset as part of "startspaces" */ ! if (virtual_active() && bd.is_short && *bd.textstart == NUL) { pos_T vpos; --- 1856,1862 ---- #ifdef FEAT_VIRTUALEDIT /* If the range starts in virtual space, count the initial * coladd offset as part of "startspaces" */ ! if (virtual_op && bd.is_short && *bd.textstart == NUL) { pos_T vpos; *************** *** 1877,1883 **** && bd.end_char_vcols > 0 ? bd.end_char_vcols - 1 : 0); /* Figure out how many characters to replace. */ numc = oap->end_vcol - oap->start_vcol + 1; ! if (bd.is_short && (!virtual_active() || bd.is_MAX)) numc -= (oap->end_vcol - bd.end_vcol) + 1; /* oldlen includes textlen, so don't double count */ n += numc - bd.textlen; --- 1877,1883 ---- && bd.end_char_vcols > 0 ? bd.end_char_vcols - 1 : 0); /* Figure out how many characters to replace. */ numc = oap->end_vcol - oap->start_vcol + 1; ! if (bd.is_short && (!virtual_op || bd.is_MAX)) numc -= (oap->end_vcol - bd.end_vcol) + 1; /* oldlen includes textlen, so don't double count */ n += numc - bd.textlen; *************** *** 1955,1968 **** coladvance_force(getviscol()); if (curwin->w_cursor.lnum == oap->end.lnum) getvpos(&oap->end, end_vcol); - pchar(curwin->w_cursor, c); } #endif pchar(curwin->w_cursor, c); } } #ifdef FEAT_VIRTUALEDIT ! else if (virtual_active() && curwin->w_cursor.lnum == oap->end.lnum) { int virtcols = oap->end.coladd; --- 1955,1967 ---- coladvance_force(getviscol()); if (curwin->w_cursor.lnum == oap->end.lnum) getvpos(&oap->end, end_vcol); } #endif pchar(curwin->w_cursor, c); } } #ifdef FEAT_VIRTUALEDIT ! else if (virtual_op && curwin->w_cursor.lnum == oap->end.lnum) { int virtcols = oap->end.coladd; *************** *** 2329,2335 **** return FALSE; if ((l > curwin->w_cursor.col) && !lineempty(curwin->w_cursor.lnum) ! && !virtual_active()) inc_cursor(); #ifdef FEAT_VISUALEXTRA --- 2328,2334 ---- return FALSE; if ((l > curwin->w_cursor.col) && !lineempty(curwin->w_cursor.lnum) ! && !virtual_op) inc_cursor(); #ifdef FEAT_VISUALEXTRA *************** *** 2592,2598 **** { startcol = oap->start.col; #ifdef FEAT_VIRTUALEDIT ! if (virtual_active()) { getvcol(curwin, &oap->start, &cs, NUL, &ce); if (ce != cs && oap->start.coladd > 0) --- 2591,2597 ---- { startcol = oap->start.col; #ifdef FEAT_VIRTUALEDIT ! if (virtual_op) { getvcol(curwin, &oap->start, &cs, NUL, &ce); if (ce != cs && oap->start.coladd > 0) *************** *** 2611,2617 **** { endcol = oap->end.col; #ifdef FEAT_VIRTUALEDIT ! if (virtual_active()) { getvcol(curwin, &oap->end, &cs, NUL, &ce); if (p[endcol] == NUL || (cs + oap->end.coladd < ce --- 2610,2616 ---- { endcol = oap->end.col; #ifdef FEAT_VIRTUALEDIT ! if (virtual_op) { getvcol(curwin, &oap->end, &cs, NUL, &ce); if (p[endcol] == NUL || (cs + oap->end.coladd < ce *************** *** 4378,4384 **** * Disadvantage: can lead to trailing spaces when the line is * short where the text is put */ /* if (!is_del || oap->op_type == OP_APPEND) */ ! if (oap->op_type == OP_APPEND || virtual_active()) bdp->endspaces = oap->end_vcol - bdp->end_vcol + oap->inclusive; else --- 4377,4383 ---- * Disadvantage: can lead to trailing spaces when the line is * short where the text is put */ /* if (!is_del || oap->op_type == OP_APPEND) */ ! if (oap->op_type == OP_APPEND || virtual_op) bdp->endspaces = oap->end_vcol - bdp->end_vcol + oap->inclusive; else *************** *** 5527,5533 **** --- 5526,5538 ---- switch (VIsual_mode) { case Ctrl_V: + # ifdef FEAT_VIRTUALEDIT + virtual_op = virtual_active(); + # endif block_prep(&oparg, &bd, lnum, 0); + # ifdef FEAT_VIRTUALEDIT + virtual_op = MAYBE; + # endif char_count_cursor += line_count_info(bd.textstart, &word_count_cursor, (long)bd.textlen, eol_size); break; *** ../vim61.013/src/undo.c Sun Feb 17 19:50:52 2002 --- src/undo.c Tue Apr 9 22:22:46 2002 *************** *** 667,673 **** { curwin->w_cursor.col = curbuf->b_u_curhead->uh_cursor.col; #ifdef FEAT_VIRTUALEDIT ! if (curbuf->b_u_curhead->uh_cursor_vcol >= 0) coladvance((colnr_T)curbuf->b_u_curhead->uh_cursor_vcol); else curwin->w_cursor.coladd = 0; --- 667,673 ---- { curwin->w_cursor.col = curbuf->b_u_curhead->uh_cursor.col; #ifdef FEAT_VIRTUALEDIT ! if (virtual_active() && curbuf->b_u_curhead->uh_cursor_vcol >= 0) coladvance((colnr_T)curbuf->b_u_curhead->uh_cursor_vcol); else curwin->w_cursor.coladd = 0; *** ../vim61.013/src/version.c Tue Apr 9 21:34:55 2002 --- src/version.c Tue Apr 9 22:35:52 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 14, /**/ -- hundred-and-one symptoms of being an internet addict: 120. You ask a friend, "What's that big shiny thing?" He says, "It's the sun." /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///