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.792 < prev    next >
Encoding:
Internet Message Format  |  2013-01-29  |  3.9 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.792
  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.792
  11. Problem:    ":substitute" works differently without confirmation.
  12. Solution:   Do not change the text when asking for confirmation, only display
  13.         it.
  14. Files:        src/ex_cmds.c
  15.  
  16.  
  17. *** ../vim-7.3.791/src/ex_cmds.c    2013-01-17 18:33:58.000000000 +0100
  18. --- src/ex_cmds.c    2013-01-30 16:01:58.000000000 +0100
  19. ***************
  20. *** 4727,4732 ****
  21. --- 4727,4734 ----
  22.               }
  23.               else
  24.               {
  25. +                 char_u *orig_line = NULL;
  26. +                 int    len_change = 0;
  27.   #ifdef FEAT_FOLDING
  28.                   int save_p_fen = curwin->w_p_fen;
  29.   
  30. ***************
  31. *** 4737,4745 ****
  32.                   temp = RedrawingDisabled;
  33.                   RedrawingDisabled = 0;
  34.   
  35.                   search_match_lines = regmatch.endpos[0].lnum
  36.                             - regmatch.startpos[0].lnum;
  37. !                 search_match_endcol = regmatch.endpos[0].col;
  38.                   highlight_match = TRUE;
  39.   
  40.                   update_topline();
  41. --- 4739,4781 ----
  42.                   temp = RedrawingDisabled;
  43.                   RedrawingDisabled = 0;
  44.   
  45. +                 if (new_start != NULL)
  46. +                 {
  47. +                 /* There already was a substitution, we would
  48. +                  * like to show this to the user.  We cannot
  49. +                  * really update the line, it would change
  50. +                  * what matches.  Temporarily replace the line
  51. +                  * and change it back afterwards. */
  52. +                 orig_line = vim_strsave(ml_get(lnum));
  53. +                 if (orig_line != NULL)
  54. +                 {
  55. +                     char_u *new_line = concat_str(new_start,
  56. +                              sub_firstline + copycol);
  57. +                     if (new_line == NULL)
  58. +                     {
  59. +                     vim_free(orig_line);
  60. +                     orig_line = NULL;
  61. +                     }
  62. +                     else
  63. +                     {
  64. +                     /* Position the cursor relative to the
  65. +                      * end of the line, the previous
  66. +                      * substitute may have inserted or
  67. +                      * deleted characters before the
  68. +                      * cursor. */
  69. +                     len_change = STRLEN(new_line)
  70. +                               - STRLEN(orig_line);
  71. +                     curwin->w_cursor.col += len_change;
  72. +                     ml_replace(lnum, new_line, FALSE);
  73. +                     }
  74. +                 }
  75. +                 }
  76.                   search_match_lines = regmatch.endpos[0].lnum
  77.                             - regmatch.startpos[0].lnum;
  78. !                 search_match_endcol = regmatch.endpos[0].col
  79. !                                  + len_change;
  80.                   highlight_match = TRUE;
  81.   
  82.                   update_topline();
  83. ***************
  84. *** 4781,4786 ****
  85. --- 4817,4826 ----
  86.                   msg_didout = FALSE;    /* don't scroll up */
  87.                   msg_col = 0;
  88.                   gotocmdline(TRUE);
  89. +                 /* restore the line */
  90. +                 if (orig_line != NULL)
  91. +                 ml_replace(lnum, orig_line, FALSE);
  92.               }
  93.   
  94.               need_wait_return = FALSE; /* no hit-return prompt */
  95. ***************
  96. *** 5045,5058 ****
  97.            * The check for nmatch_tl is needed for when multi-line
  98.            * matching must replace the lines before trying to do another
  99.            * match, otherwise "\@<=" won't work.
  100. -          * When asking the user we like to show the already replaced
  101. -          * text, but don't do it when "\<@=" or "\<@!" is used, it
  102. -          * changes what matches.
  103.            * When the match starts below where we start searching also
  104.            * need to replace the line first (using \zs after \n).
  105.            */
  106.           if (lastone
  107. -             || (do_ask && !re_lookbehind(regmatch.regprog))
  108.               || nmatch_tl > 0
  109.               || (nmatch = vim_regexec_multi(®match, curwin,
  110.                               curbuf, sub_firstlnum,
  111. --- 5085,5094 ----
  112. *** ../vim-7.3.791/src/version.c    2013-01-30 14:55:35.000000000 +0100
  113. --- src/version.c    2013-01-30 16:25:36.000000000 +0100
  114. ***************
  115. *** 727,728 ****
  116. --- 727,730 ----
  117.   {   /* Add new patch number below this line */
  118. + /**/
  119. +     792,
  120.   /**/
  121.  
  122. -- 
  123. Trees moving back and forth is what makes the wind blow.
  124.  
  125.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  126. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  127. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  128.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  129.