Loading ...
Sorry, an error occurred while loading the content.

Patch 6.1.006

Expand Messages
  • Bram Moolenaar
    Patch 6.1.006 Problem: When using P in Visual mode to put linewise selected text, the wrong text is deleted. (Jakub Turski) Solution: Put the text
    Message 1 of 1 , Apr 3, 2002
    • 0 Attachment
      Patch 6.1.006
      Problem: When using "P" in Visual mode to put linewise selected text, the
      wrong text is deleted. (Jakub Turski)
      Solution: Put the text before the Visual area and correct the text to be
      deleted for the inserted lines.
      Also fix that "p" of linewise text in Visual block mode doesn't
      work correctly.
      Files: src/normal.c, src/ops.c


      *** ../vim61.005/src/normal.c Sun Mar 24 12:36:35 2002
      --- src/normal.c Wed Apr 3 22:08:14 2002
      ***************
      *** 7890,7911 ****
      {
      /* Putting in Visual mode: The put text replaces the selected
      * text. First put the register at the end of the Visual
      ! * selection, then delete the selected text. */
      curpos = curwin->w_cursor;
      if (VIsual_mode == Ctrl_V)
      {
      getvcols(curwin, &curwin->w_cursor, &VIsual, &left, &right);
      ! if (lt(VIsual, curwin->w_cursor))
      ! curwin->w_cursor = VIsual;
      coladvance(right);
      }
      ! else if (lt(curwin->w_cursor, VIsual))
      ! curwin->w_cursor = VIsual;
      if (VIsual_mode == 'v' && *p_sel == 'e')
      dir = BACKWARD;
      else
      {
      ! if (dir == BACKWARD)
      flags |= PUT_LINE_BACKWARD;
      dir = FORWARD;
      }
      --- 7890,7923 ----
      {
      /* Putting in Visual mode: The put text replaces the selected
      * text. First put the register at the end of the Visual
      ! * selection, then delete the selected text. In some cases the
      ! * register is put before the Visual selection. */
      ! if (lt(VIsual, curwin->w_cursor))
      ! {
      ! curbuf->b_visual_start = VIsual;
      ! curbuf->b_visual_end = curwin->w_cursor;
      ! }
      ! else
      ! {
      ! curbuf->b_visual_start = curwin->w_cursor;
      ! curbuf->b_visual_end = VIsual;
      ! }
      curpos = curwin->w_cursor;
      if (VIsual_mode == Ctrl_V)
      {
      getvcols(curwin, &curwin->w_cursor, &VIsual, &left, &right);
      ! curwin->w_cursor = curbuf->b_visual_start;
      coladvance(right);
      }
      ! else
      ! curwin->w_cursor = curbuf->b_visual_end;
      if (VIsual_mode == 'v' && *p_sel == 'e')
      dir = BACKWARD;
      else
      {
      ! /* Put linewise text above a characterwise or blockwise
      ! * selected Visual area; handled in do_put(). */
      ! if (dir == BACKWARD && VIsual_mode != 'V')
      flags |= PUT_LINE_BACKWARD;
      dir = FORWARD;
      }
      ***************
      *** 7923,7928 ****
      --- 7935,7952 ----
      #ifdef FEAT_VISUAL
      if (VIsual_active)
      {
      + /* If linewise text was put above the Visual area, need to correct
      + * the line numbers to shift the Visual area down. */
      + if ((flags & PUT_LINE_BACKWARD)
      + && curbuf->b_visual_start.lnum > curbuf->b_op_end.lnum)
      + {
      + linenr_T l;
      +
      + l = curbuf->b_op_end.lnum - curbuf->b_op_start.lnum + 1;
      + curpos.lnum += l;
      + VIsual.lnum += l;
      + }
      +
      /* Now delete the selected text. */
      cap->cmdchar = 'd';
      cap->nchar = NUL;
      *** ../vim61.005/src/ops.c Sat Mar 2 13:02:33 2002
      --- src/ops.c Wed Apr 3 22:27:05 2002
      ***************
      *** 2985,2992 ****
      y_array = y_current->y_array;
      }

      ! if ((flags & PUT_LINE_BACKWARD) && y_type == MLINE)
      ! dir = BACKWARD;
      if (flags & PUT_LINE) /* :put command */
      y_type = MLINE;

      --- 2985,3012 ----
      y_array = y_current->y_array;
      }

      ! #ifdef FEAT_VISUAL
      ! if (y_type == MLINE)
      ! {
      ! if (flags & PUT_LINE_BACKWARD)
      ! {
      ! /* "P" in Visual mode: Put before the Visual area instead of after
      ! * it. It's OK to change the cursor position here (special
      ! * case!). */
      ! dir = BACKWARD;
      ! curwin->w_cursor = curbuf->b_visual_start;
      ! }
      ! else if (VIsual_active && VIsual_mode == Ctrl_V)
      ! {
      ! /* "p" in Visual block mode with linewise text: put below the
      ! * block. */
      ! curwin->w_cursor = curbuf->b_visual_end;
      ! }
      ! curbuf->b_op_start = curwin->w_cursor; /* default for '[ mark */
      ! curbuf->b_op_end = curwin->w_cursor; /* default for '] mark */
      ! }
      ! #endif
      !
      if (flags & PUT_LINE) /* :put command */
      y_type = MLINE;

      *** ../vim61.005/src/version.c Sat Mar 30 20:03:55 2002
      --- src/version.c Wed Apr 3 22:29:25 2002
      ***************
      *** 608,609 ****
      --- 608,611 ----
      { /* Add new patch number below this line */
      + /**/
      + 6,
      /**/

      --
      "I simultaneously try to keep my head in the clouds and my feet on the
      ground. Sometimes it's a stretch, though." -- Larry Wall

      /// Bram Moolenaar -- Bram@... -- 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 ///
    Your message has been successfully submitted and would be delivered to recipients shortly.