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 / 7.4 / 7.4.064 < prev    next >
Encoding:
Internet Message Format  |  2013-11-03  |  5.2 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.4.064
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.4.064
  11. Problem:    When replacing a character in Visual block mode, entering a CR
  12.             does not cause a repeated line break.
  13. Solution:   Recognize the situation and repeat the line break. (Christian
  14.             Brabandt)
  15. Files:      src/normal.c, src/ops.c, src/testdir/test39.in,
  16.             src/testdir/test39.ok
  17.  
  18.  
  19. *** ../vim-7.4.063/src/normal.c    2013-09-25 18:54:20.000000000 +0200
  20. --- src/normal.c    2013-11-04 01:14:53.000000000 +0100
  21. ***************
  22. *** 7036,7041 ****
  23. --- 7036,7048 ----
  24.       {
  25.       if (got_int)
  26.           reset_VIsual();
  27. +     if (had_ctrl_v)
  28. +     {
  29. +         if (cap->nchar == '\r')
  30. +         cap->nchar = -1;
  31. +         else if (cap->nchar == '\n')
  32. +         cap->nchar = -2;
  33. +     }
  34.       nv_operator(cap);
  35.       return;
  36.       }
  37. *** ../vim-7.4.063/src/ops.c    2013-11-02 23:59:30.000000000 +0100
  38. --- src/ops.c    2013-11-04 01:28:54.000000000 +0100
  39. ***************
  40. *** 2074,2083 ****
  41. --- 2074,2088 ----
  42.       char_u        *newp, *oldp;
  43.       size_t        oldlen;
  44.       struct block_def    bd;
  45. +     char_u        *after_p = NULL;
  46. +     int            had_ctrl_v_cr = (c == -1 || c == -2);
  47.   
  48.       if ((curbuf->b_ml.ml_flags & ML_EMPTY ) || oap->empty)
  49.       return OK;        /* nothing to do */
  50.   
  51. +     if (had_ctrl_v_cr)
  52. +     c = (c == -1 ? '\r' : '\n');
  53.   #ifdef FEAT_MBYTE
  54.       if (has_mbyte)
  55.       mb_adjust_opend(oap);
  56. ***************
  57. *** 2164,2188 ****
  58.           /* insert pre-spaces */
  59.           copy_spaces(newp + bd.textcol, (size_t)bd.startspaces);
  60.           /* insert replacement chars CHECK FOR ALLOCATED SPACE */
  61. ! #ifdef FEAT_MBYTE
  62. !         if (has_mbyte)
  63.           {
  64. !         n = (int)STRLEN(newp);
  65. !         while (--num_chars >= 0)
  66. !             n += (*mb_char2bytes)(c, newp + n);
  67.           }
  68.           else
  69. - #endif
  70. -         copy_chars(newp + STRLEN(newp), (size_t)numc, c);
  71. -         if (!bd.is_short)
  72.           {
  73. !         /* insert post-spaces */
  74. !         copy_spaces(newp + STRLEN(newp), (size_t)bd.endspaces);
  75. !         /* copy the part after the changed part */
  76. !         STRMOVE(newp + STRLEN(newp), oldp);
  77.           }
  78.           /* replace the line */
  79.           ml_replace(curwin->w_cursor.lnum, newp, FALSE);
  80.       }
  81.       }
  82.       else
  83. --- 2169,2211 ----
  84.           /* insert pre-spaces */
  85.           copy_spaces(newp + bd.textcol, (size_t)bd.startspaces);
  86.           /* insert replacement chars CHECK FOR ALLOCATED SPACE */
  87. !         /* -1/-2 is used for entering CR literally. */
  88. !         if (had_ctrl_v_cr || (c != '\r' && c != '\n'))
  89.           {
  90. ! #ifdef FEAT_MBYTE
  91. !         if (has_mbyte)
  92. !         {
  93. !             n = (int)STRLEN(newp);
  94. !             while (--num_chars >= 0)
  95. !             n += (*mb_char2bytes)(c, newp + n);
  96. !         }
  97. !         else
  98. ! #endif
  99. !             copy_chars(newp + STRLEN(newp), (size_t)numc, c);
  100. !         if (!bd.is_short)
  101. !         {
  102. !             /* insert post-spaces */
  103. !             copy_spaces(newp + STRLEN(newp), (size_t)bd.endspaces);
  104. !             /* copy the part after the changed part */
  105. !             STRMOVE(newp + STRLEN(newp), oldp);
  106. !         }
  107.           }
  108.           else
  109.           {
  110. !         /* Replacing with \r or \n means splitting the line. */
  111. !         after_p = alloc_check((unsigned)oldlen + 1 + n - STRLEN(newp));
  112. !         if (after_p != NULL)
  113. !             STRMOVE(after_p, oldp);
  114.           }
  115.           /* replace the line */
  116.           ml_replace(curwin->w_cursor.lnum, newp, FALSE);
  117. +         if (after_p != NULL)
  118. +         {
  119. +         ml_append(curwin->w_cursor.lnum++, after_p, 0, FALSE);
  120. +         appended_lines_mark(curwin->w_cursor.lnum, 1L);
  121. +         oap->end.lnum++;
  122. +         vim_free(after_p);
  123. +         }
  124.       }
  125.       }
  126.       else
  127. *** ../vim-7.4.063/src/testdir/test39.in    2013-03-07 18:30:38.000000000 +0100
  128. --- src/testdir/test39.in    2013-11-04 01:36:34.000000000 +0100
  129. ***************
  130. *** 32,37 ****
  131. --- 32,41 ----
  132.   doh dutVkUj
  133.   :" Uppercase part of two lines
  134.   ddppi333k0i222fyllvjfuUk
  135. + :" visual replace using Enter or NL
  136. + G3o123456789k05l2jr
  137. G3o98765k02l2jr
  138. + G3o123456789k05l2jr
  139. + G3o98765k02l2jr
  140.   :/^the/,$w >> test.out
  141.   :qa!
  142.   ENDTEST
  143. *** ../vim-7.4.063/src/testdir/test39.ok    2013-03-07 18:28:51.000000000 +0100
  144. --- src/testdir/test39.ok    2013-11-04 01:37:12.000000000 +0100
  145. ***************
  146. *** 11,13 ****
  147. --- 11,31 ----
  148.   DOH DUT
  149.   222the yoUTUSSEUU END
  150.   333THE YOUTUâ–€euu end
  151. + 12345
  152. + 789
  153. + 12345
  154. + 789
  155. + 12345
  156. + 789
  157. + 98
  158. 65
  159. + 98
  160. 65
  161. + 98
  162. 65
  163. + 12345
  164. + 789
  165. + 12345
  166. + 789
  167. + 12345
  168. + 789
  169. + 9865
  170. + 9865
  171. + 9865
  172. *** ../vim-7.4.063/src/version.c    2013-11-04 00:34:47.000000000 +0100
  173. --- src/version.c    2013-11-04 01:39:26.000000000 +0100
  174. ***************
  175. *** 740,741 ****
  176. --- 740,743 ----
  177.   {   /* Add new patch number below this line */
  178. + /**/
  179. +     64,
  180.   /**/
  181.  
  182. -- 
  183. So when I saw the post to comp.editors, I rushed over to the FTP site to
  184. grab it.  So I yank apart the tarball, light x candles, where x= the
  185. vim version multiplied by the md5sum of the source divided by the MAC of
  186. my NIC (8A3FA78155A8A1D346C3C4A), put on black robes, dim the lights,
  187. wave a dead chicken over the hard drive, and summon the power of GNU GCC
  188. with the magic words "make config ; make!".
  189.         [Jason Spence, compiling Vim 5.0]
  190.  
  191.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  192. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  193. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  194.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  195.