home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.1.006 < prev    next >
Encoding:
Internet Message Format  |  2002-04-02  |  4.8 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.1.006
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.1.006
  11. Problem:    When using "P" in Visual mode to put linewise selected text, the
  12.         wrong text is deleted. (Jakub Turski)
  13. Solution:   Put the text before the Visual area and correct the text to be
  14.         deleted for the inserted lines.
  15.         Also fix that "p" of linewise text in Visual block mode doesn't
  16.         work correctly.
  17. Files:        src/normal.c, src/ops.c
  18.  
  19.  
  20. *** ../vim61.005/src/normal.c    Sun Mar 24 12:36:35 2002
  21. --- src/normal.c    Wed Apr  3 22:08:14 2002
  22. ***************
  23. *** 7890,7911 ****
  24.       {
  25.           /* Putting in Visual mode: The put text replaces the selected
  26.            * text.  First put the register at the end of the Visual
  27. !          * selection, then delete the selected text. */
  28.           curpos = curwin->w_cursor;
  29.           if (VIsual_mode == Ctrl_V)
  30.           {
  31.           getvcols(curwin, &curwin->w_cursor, &VIsual, &left, &right);
  32. !         if (lt(VIsual, curwin->w_cursor))
  33. !             curwin->w_cursor = VIsual;
  34.           coladvance(right);
  35.           }
  36. !         else if (lt(curwin->w_cursor, VIsual))
  37. !         curwin->w_cursor = VIsual;
  38.           if (VIsual_mode == 'v' && *p_sel == 'e')
  39.           dir = BACKWARD;
  40.           else
  41.           {
  42. !         if (dir == BACKWARD)
  43.               flags |= PUT_LINE_BACKWARD;
  44.           dir = FORWARD;
  45.           }
  46. --- 7890,7923 ----
  47.       {
  48.           /* Putting in Visual mode: The put text replaces the selected
  49.            * text.  First put the register at the end of the Visual
  50. !          * selection, then delete the selected text.  In some cases the
  51. !          * register is put before the Visual selection. */
  52. !         if (lt(VIsual, curwin->w_cursor))
  53. !         {
  54. !         curbuf->b_visual_start = VIsual;
  55. !         curbuf->b_visual_end = curwin->w_cursor;
  56. !         }
  57. !         else
  58. !         {
  59. !         curbuf->b_visual_start = curwin->w_cursor;
  60. !         curbuf->b_visual_end = VIsual;
  61. !         }
  62.           curpos = curwin->w_cursor;
  63.           if (VIsual_mode == Ctrl_V)
  64.           {
  65.           getvcols(curwin, &curwin->w_cursor, &VIsual, &left, &right);
  66. !         curwin->w_cursor = curbuf->b_visual_start;
  67.           coladvance(right);
  68.           }
  69. !         else
  70. !         curwin->w_cursor = curbuf->b_visual_end;
  71.           if (VIsual_mode == 'v' && *p_sel == 'e')
  72.           dir = BACKWARD;
  73.           else
  74.           {
  75. !         /* Put linewise text above a characterwise or blockwise
  76. !          * selected Visual area; handled in do_put(). */
  77. !         if (dir == BACKWARD && VIsual_mode != 'V')
  78.               flags |= PUT_LINE_BACKWARD;
  79.           dir = FORWARD;
  80.           }
  81. ***************
  82. *** 7923,7928 ****
  83. --- 7935,7952 ----
  84.   #ifdef FEAT_VISUAL
  85.       if (VIsual_active)
  86.       {
  87. +         /* If linewise text was put above the Visual area, need to correct
  88. +          * the line numbers to shift the Visual area down. */
  89. +         if ((flags & PUT_LINE_BACKWARD)
  90. +             && curbuf->b_visual_start.lnum > curbuf->b_op_end.lnum)
  91. +         {
  92. +         linenr_T l;
  93. +         l = curbuf->b_op_end.lnum - curbuf->b_op_start.lnum + 1;
  94. +         curpos.lnum += l;
  95. +         VIsual.lnum += l;
  96. +         }
  97.           /* Now delete the selected text. */
  98.           cap->cmdchar = 'd';
  99.           cap->nchar = NUL;
  100. *** ../vim61.005/src/ops.c    Sat Mar  2 13:02:33 2002
  101. --- src/ops.c    Wed Apr  3 22:27:05 2002
  102. ***************
  103. *** 2985,2992 ****
  104.       y_array = y_current->y_array;
  105.       }
  106.   
  107. !     if ((flags & PUT_LINE_BACKWARD) && y_type == MLINE)
  108. !     dir = BACKWARD;
  109.       if (flags & PUT_LINE)        /* :put command */
  110.       y_type = MLINE;
  111.   
  112. --- 2985,3012 ----
  113.       y_array = y_current->y_array;
  114.       }
  115.   
  116. ! #ifdef FEAT_VISUAL
  117. !     if (y_type == MLINE)
  118. !     {
  119. !     if (flags & PUT_LINE_BACKWARD)
  120. !     {
  121. !         /* "P" in Visual mode: Put before the Visual area instead of after
  122. !          * it.  It's OK to change the cursor position here (special
  123. !          * case!). */
  124. !         dir = BACKWARD;
  125. !         curwin->w_cursor = curbuf->b_visual_start;
  126. !     }
  127. !     else if (VIsual_active && VIsual_mode == Ctrl_V)
  128. !     {
  129. !         /* "p" in Visual block mode with linewise text: put below the
  130. !          * block. */
  131. !         curwin->w_cursor = curbuf->b_visual_end;
  132. !     }
  133. !     curbuf->b_op_start = curwin->w_cursor;    /* default for '[ mark */
  134. !     curbuf->b_op_end = curwin->w_cursor;    /* default for '] mark */
  135. !     }
  136. ! #endif
  137.       if (flags & PUT_LINE)        /* :put command */
  138.       y_type = MLINE;
  139.   
  140. *** ../vim61.005/src/version.c    Sat Mar 30 20:03:55 2002
  141. --- src/version.c    Wed Apr  3 22:29:25 2002
  142. ***************
  143. *** 608,609 ****
  144. --- 608,611 ----
  145.   {   /* Add new patch number below this line */
  146. + /**/
  147. +     6,
  148.   /**/
  149.  
  150. -- 
  151. "I simultaneously try to keep my head in the clouds and my feet on the
  152. ground.  Sometimes it's a stretch, though."              -- Larry Wall
  153.  
  154.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  155. ///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
  156. \\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
  157.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  158.