Loading ...
Sorry, an error occurred while loading the content.

Patch 7.3.792

Expand Messages
  • Bram Moolenaar
    Patch 7.3.792 Problem: :substitute works differently without confirmation. Solution: Do not change the text when asking for confirmation, only display
    Message 1 of 1 , Jan 30, 2013
    • 0 Attachment
      Patch 7.3.792
      Problem: ":substitute" works differently without confirmation.
      Solution: Do not change the text when asking for confirmation, only display
      it.
      Files: src/ex_cmds.c


      *** ../vim-7.3.791/src/ex_cmds.c 2013-01-17 18:33:58.000000000 +0100
      --- src/ex_cmds.c 2013-01-30 16:01:58.000000000 +0100
      ***************
      *** 4727,4732 ****
      --- 4727,4734 ----
      }
      else
      {
      + char_u *orig_line = NULL;
      + int len_change = 0;
      #ifdef FEAT_FOLDING
      int save_p_fen = curwin->w_p_fen;

      ***************
      *** 4737,4745 ****
      temp = RedrawingDisabled;
      RedrawingDisabled = 0;

      search_match_lines = regmatch.endpos[0].lnum
      - regmatch.startpos[0].lnum;
      ! search_match_endcol = regmatch.endpos[0].col;
      highlight_match = TRUE;

      update_topline();
      --- 4739,4781 ----
      temp = RedrawingDisabled;
      RedrawingDisabled = 0;

      + if (new_start != NULL)
      + {
      + /* There already was a substitution, we would
      + * like to show this to the user. We cannot
      + * really update the line, it would change
      + * what matches. Temporarily replace the line
      + * and change it back afterwards. */
      + orig_line = vim_strsave(ml_get(lnum));
      + if (orig_line != NULL)
      + {
      + char_u *new_line = concat_str(new_start,
      + sub_firstline + copycol);
      +
      + if (new_line == NULL)
      + {
      + vim_free(orig_line);
      + orig_line = NULL;
      + }
      + else
      + {
      + /* Position the cursor relative to the
      + * end of the line, the previous
      + * substitute may have inserted or
      + * deleted characters before the
      + * cursor. */
      + len_change = STRLEN(new_line)
      + - STRLEN(orig_line);
      + curwin->w_cursor.col += len_change;
      + ml_replace(lnum, new_line, FALSE);
      + }
      + }
      + }
      +
      search_match_lines = regmatch.endpos[0].lnum
      - regmatch.startpos[0].lnum;
      ! search_match_endcol = regmatch.endpos[0].col
      ! + len_change;
      highlight_match = TRUE;

      update_topline();
      ***************
      *** 4781,4786 ****
      --- 4817,4826 ----
      msg_didout = FALSE; /* don't scroll up */
      msg_col = 0;
      gotocmdline(TRUE);
      +
      + /* restore the line */
      + if (orig_line != NULL)
      + ml_replace(lnum, orig_line, FALSE);
      }

      need_wait_return = FALSE; /* no hit-return prompt */
      ***************
      *** 5045,5058 ****
      * The check for nmatch_tl is needed for when multi-line
      * matching must replace the lines before trying to do another
      * match, otherwise "\@<=" won't work.
      - * When asking the user we like to show the already replaced
      - * text, but don't do it when "\<@=" or "\<@!" is used, it
      - * changes what matches.
      * When the match starts below where we start searching also
      * need to replace the line first (using \zs after \n).
      */
      if (lastone
      - || (do_ask && !re_lookbehind(regmatch.regprog))
      || nmatch_tl > 0
      || (nmatch = vim_regexec_multi(®match, curwin,
      curbuf, sub_firstlnum,
      --- 5085,5094 ----
      *** ../vim-7.3.791/src/version.c 2013-01-30 14:55:35.000000000 +0100
      --- src/version.c 2013-01-30 16:25:36.000000000 +0100
      ***************
      *** 727,728 ****
      --- 727,730 ----
      { /* Add new patch number below this line */
      + /**/
      + 792,
      /**/

      --
      Trees moving back and forth is what makes the wind blow.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ an exciting new programming language -- http://www.Zimbu.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    Your message has been successfully submitted and would be delivered to recipients shortly.