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.052 < prev    next >
Encoding:
Internet Message Format  |  2013-10-05  |  5.8 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.4.052
  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.052
  11. Problem:    With 'fo' set to "a2" inserting a space in the first column may
  12.         cause the cursor to jump to the previous line.
  13. Solution:   Handle the case when there is no comment leader properly. (Tor
  14.         Perkins)  Also fix that cursor is in the wrong place when spaces
  15.         get replaced with a Tab.
  16. Files:        src/misc1.c, src/ops.c, src/testdir/test68.in,
  17.         src/testdir/test68.ok
  18.  
  19.  
  20. *** ../vim-7.4.051/src/misc1.c    2013-09-05 21:41:35.000000000 +0200
  21. --- src/misc1.c    2013-10-06 17:46:18.000000000 +0200
  22. ***************
  23. *** 303,312 ****
  24.       ml_replace(curwin->w_cursor.lnum, newline, FALSE);
  25.       if (flags & SIN_CHANGED)
  26.           changed_bytes(curwin->w_cursor.lnum, 0);
  27. !     /* Correct saved cursor position if it's after the indent. */
  28. !     if (saved_cursor.lnum == curwin->w_cursor.lnum
  29. !                 && saved_cursor.col >= (colnr_T)(p - oldline))
  30. !         saved_cursor.col += ind_len - (colnr_T)(p - oldline);
  31.       retval = TRUE;
  32.       }
  33.       else
  34. --- 303,320 ----
  35.       ml_replace(curwin->w_cursor.lnum, newline, FALSE);
  36.       if (flags & SIN_CHANGED)
  37.           changed_bytes(curwin->w_cursor.lnum, 0);
  38. !     /* Correct saved cursor position if it is in this line. */
  39. !     if (saved_cursor.lnum == curwin->w_cursor.lnum)
  40. !     {
  41. !         if (saved_cursor.col >= (colnr_T)(p - oldline))
  42. !         /* cursor was after the indent, adjust for the number of
  43. !          * bytes added/removed */
  44. !         saved_cursor.col += ind_len - (colnr_T)(p - oldline);
  45. !         else if (saved_cursor.col >= (colnr_T)(s - newline))
  46. !         /* cursor was in the indent, and is now after it, put it back
  47. !          * at the start of the indent (replacing spaces with TAB) */
  48. !         saved_cursor.col = (colnr_T)(s - newline);
  49. !     }
  50.       retval = TRUE;
  51.       }
  52.       else
  53. ***************
  54. *** 1581,1589 ****
  55.   
  56.   #if defined(FEAT_COMMENTS) || defined(PROTO)
  57.   /*
  58. !  * get_leader_len() returns the length of the prefix of the given string
  59. !  * which introduces a comment.    If this string is not a comment then 0 is
  60. !  * returned.
  61.    * When "flags" is not NULL, it is set to point to the flags of the recognized
  62.    * comment leader.
  63.    * "backward" must be true for the "O" command.
  64. --- 1589,1597 ----
  65.   
  66.   #if defined(FEAT_COMMENTS) || defined(PROTO)
  67.   /*
  68. !  * get_leader_len() returns the length in bytes of the prefix of the given
  69. !  * string which introduces a comment.  If this string is not a comment then
  70. !  * 0 is returned.
  71.    * When "flags" is not NULL, it is set to point to the flags of the recognized
  72.    * comment leader.
  73.    * "backward" must be true for the "O" command.
  74. *** ../vim-7.4.051/src/ops.c    2013-09-25 23:24:54.000000000 +0200
  75. --- src/ops.c    2013-10-06 17:11:51.000000000 +0200
  76. ***************
  77. *** 4989,4995 ****
  78.   
  79.           /*
  80.            * When still in same paragraph, join the lines together.  But
  81. !          * first delete the comment leader from the second line.
  82.            */
  83.           if (!is_end_par)
  84.           {
  85. --- 4989,4995 ----
  86.   
  87.           /*
  88.            * When still in same paragraph, join the lines together.  But
  89. !          * first delete the leader from the second line.
  90.            */
  91.           if (!is_end_par)
  92.           {
  93. ***************
  94. *** 4999,5009 ****
  95.           if (line_count < 0 && u_save_cursor() == FAIL)
  96.               break;
  97.   #ifdef FEAT_COMMENTS
  98. -         (void)del_bytes((long)next_leader_len, FALSE, FALSE);
  99.           if (next_leader_len > 0)
  100.               mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L,
  101.                                 (long)-next_leader_len);
  102.   #endif
  103.           curwin->w_cursor.lnum--;
  104.           if (do_join(2, TRUE, FALSE, FALSE) == FAIL)
  105.           {
  106. --- 4999,5023 ----
  107.           if (line_count < 0 && u_save_cursor() == FAIL)
  108.               break;
  109.   #ifdef FEAT_COMMENTS
  110.           if (next_leader_len > 0)
  111. +         {
  112. +             (void)del_bytes((long)next_leader_len, FALSE, FALSE);
  113.               mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L,
  114.                                 (long)-next_leader_len);
  115. +         } else
  116.   #endif
  117. +             if (second_indent > 0)  /* the "leader" for FO_Q_SECOND */
  118. +         {
  119. +             char_u *p = ml_get_curline();
  120. +             int indent = skipwhite(p) - p;
  121. +             if (indent > 0)
  122. +             {
  123. +             (void)del_bytes(indent, FALSE, FALSE);
  124. +             mark_col_adjust(curwin->w_cursor.lnum,
  125. +                            (colnr_T)0, 0L, (long)-indent);
  126. +               }
  127. +         }
  128.           curwin->w_cursor.lnum--;
  129.           if (do_join(2, TRUE, FALSE, FALSE) == FAIL)
  130.           {
  131. *** ../vim-7.4.051/src/testdir/test68.in    2012-07-25 15:57:06.000000000 +0200
  132. --- src/testdir/test68.in    2013-10-06 16:20:33.000000000 +0200
  133. ***************
  134. *** 62,67 ****
  135. --- 62,81 ----
  136.   }
  137.   
  138.   STARTTEST
  139. + /^{/+3
  140. + :set tw=5 fo=t2a si
  141. + i  A_
  142. + ENDTEST
  143. + {
  144. +   x a
  145. +   b
  146. +  c
  147. + }
  148. + STARTTEST
  149.   /^{/+1
  150.   :set tw=5 fo=qn comments=:#
  151.   gwap
  152. *** ../vim-7.4.051/src/testdir/test68.ok    2012-07-25 16:03:05.000000000 +0200
  153. --- src/testdir/test68.ok    2013-10-06 16:20:33.000000000 +0200
  154. ***************
  155. *** 43,48 ****
  156. --- 43,57 ----
  157.   
  158.   
  159.   {
  160. +   x a
  161. +     b_
  162. +     c
  163. + }
  164. + {
  165.   # 1 a
  166.   #   b
  167.   }
  168. *** ../vim-7.4.051/src/version.c    2013-10-06 15:46:06.000000000 +0200
  169. --- src/version.c    2013-10-06 17:25:27.000000000 +0200
  170. ***************
  171. *** 740,741 ****
  172. --- 740,743 ----
  173.   {   /* Add new patch number below this line */
  174. + /**/
  175. +     52,
  176.   /**/
  177.  
  178. -- 
  179. ARTHUR:    Will you ask your master if he wants to join my court at Camelot?!
  180. GUARD #1:  But then of course African swallows are not migratory.
  181. GUARD #2:  Oh, yeah...
  182. GUARD #1:  So they couldn't bring a coconut back anyway...
  183.                                   The Quest for the Holy Grail (Monty Python)
  184.  
  185.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  186. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  187. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  188.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  189.