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.3 / 7.3.319 < prev    next >
Encoding:
Internet Message Format  |  2012-11-20  |  4.5 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.319
  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.3.319 (after 7.3.311)
  11. Problem:    Redobuff doesn't always include changes of the completion leader.
  12. Solution:   Insert backspaces as needed. (idea by Taro Muraoka)
  13. Files:        src/edit.c
  14.  
  15.  
  16. *** ../vim-7.3.318/src/edit.c    2011-09-14 16:52:02.000000000 +0200
  17. --- src/edit.c    2011-09-21 17:59:10.000000000 +0200
  18. ***************
  19. *** 163,168 ****
  20. --- 163,169 ----
  21.   static void ins_compl_set_original_text __ARGS((char_u *str));
  22.   static void ins_compl_addfrommatch __ARGS((void));
  23.   static int  ins_compl_prep __ARGS((int c));
  24. + static void ins_compl_fixRedoBufForLeader __ARGS((char_u *ptr_arg));
  25.   static buf_T *ins_compl_next_buf __ARGS((buf_T *buf, int flag));
  26.   #if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL)
  27.   static void ins_compl_add_list __ARGS((list_T *list));
  28. ***************
  29. *** 3713,3721 ****
  30.            * memory that was used, and make sure we can redo the insert. */
  31.           if (compl_curr_match != NULL || compl_leader != NULL || c == Ctrl_E)
  32.           {
  33. -         char_u    *p;
  34. -         int    temp = 0;
  35.           /*
  36.            * If any of the original typed text has been changed, eg when
  37.            * ignorecase is set, we must add back-spaces to the redo
  38. --- 3714,3719 ----
  39. ***************
  40. *** 3726,3750 ****
  41.            */
  42.           if (compl_curr_match != NULL && compl_used_match && c != Ctrl_E)
  43.               ptr = compl_curr_match->cp_str;
  44. -         else if (compl_leader != NULL)
  45. -             ptr = compl_leader;
  46.           else
  47. !             ptr = compl_orig_text;
  48. !         if (compl_orig_text != NULL)
  49. !         {
  50. !             p = compl_orig_text;
  51. !             for (temp = 0; p[temp] != NUL && p[temp] == ptr[temp];
  52. !                                        ++temp)
  53. !             ;
  54. ! #ifdef FEAT_MBYTE
  55. !             if (temp > 0)
  56. !             temp -= (*mb_head_off)(compl_orig_text, p + temp);
  57. ! #endif
  58. !             for (p += temp; *p != NUL; mb_ptr_adv(p))
  59. !             AppendCharToRedobuff(K_BS);
  60. !         }
  61. !         if (ptr != NULL)
  62. !             AppendToRedobuffLit(ptr + temp, -1);
  63.           }
  64.   
  65.   #ifdef FEAT_CINDENT
  66. --- 3724,3732 ----
  67.            */
  68.           if (compl_curr_match != NULL && compl_used_match && c != Ctrl_E)
  69.               ptr = compl_curr_match->cp_str;
  70.           else
  71. !             ptr = NULL;
  72. !         ins_compl_fixRedoBufForLeader(ptr);
  73.           }
  74.   
  75.   #ifdef FEAT_CINDENT
  76. ***************
  77. *** 3834,3839 ****
  78. --- 3816,3859 ----
  79.   }
  80.   
  81.   /*
  82. +  * Fix the redo buffer for the completion leader replacing some of the typed
  83. +  * text.  This inserts backspaces and appends the changed text.
  84. +  * "ptr" is the known leader text or NUL.
  85. +  */
  86. +     static void
  87. + ins_compl_fixRedoBufForLeader(ptr_arg)
  88. +     char_u *ptr_arg;
  89. + {
  90. +     int        len;
  91. +     char_u  *p;
  92. +     char_u  *ptr = ptr_arg;
  93. +     if (ptr == NULL)
  94. +     {
  95. +     if (compl_leader != NULL)
  96. +         ptr = compl_leader;
  97. +     else
  98. +         return;  /* nothing to do */
  99. +     }
  100. +     if (compl_orig_text != NULL)
  101. +     {
  102. +     p = compl_orig_text;
  103. +     for (len = 0; p[len] != NUL && p[len] == ptr[len]; ++len)
  104. +         ;
  105. + #ifdef FEAT_MBYTE
  106. +     if (len > 0)
  107. +         len -= (*mb_head_off)(p, p + len);
  108. + #endif
  109. +     for (p += len; *p != NUL; mb_ptr_adv(p))
  110. +         AppendCharToRedobuff(K_BS);
  111. +     }
  112. +     else
  113. +     len = 0;
  114. +     if (ptr != NULL)
  115. +     AppendToRedobuffLit(ptr + len, -1);
  116. + }
  117. + /*
  118.    * Loops through the list of windows, loaded-buffers or non-loaded-buffers
  119.    * (depending on flag) starting from buf and looking for a non-scanned
  120.    * buffer (other than curbuf).    curbuf is special, if it is called with
  121. ***************
  122. *** 5241,5246 ****
  123. --- 5261,5270 ----
  124.       else
  125.           edit_submode = (char_u *)_(CTRL_X_MSG(ctrl_x_mode));
  126.   
  127. +     /* If any of the original typed text has been changed we need to fix
  128. +      * the redo buffer. */
  129. +     ins_compl_fixRedoBufForLeader(NULL);
  130.       /* Always add completion for the original text. */
  131.       vim_free(compl_orig_text);
  132.       compl_orig_text = vim_strnsave(line + compl_col, compl_length);
  133. *** ../vim-7.3.318/src/version.c    2011-09-21 17:33:49.000000000 +0200
  134. --- src/version.c    2011-09-21 18:21:07.000000000 +0200
  135. ***************
  136. *** 711,712 ****
  137. --- 711,714 ----
  138.   {   /* Add new patch number below this line */
  139. + /**/
  140. +     319,
  141.   /**/
  142.  
  143. -- 
  144. hundred-and-one symptoms of being an internet addict:
  145. 27. You refer to your age as 3.x.
  146.  
  147.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  148. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  149. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  150.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  151.