Re: BUG: :substitute answers (a)ll / (l)ast affect c / g flags on repetition with g and :
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 03-May-2015 03:52, h_east wrote: Hello Ingo! 2015/5/3(Sun) 4:46:50 UTC+9 Ingo Karkat: Hello Vim developers, if you do a :substitute/foo/bar/c and then choose (a)ll as the answer, a repeat of the substitution via g or : does not confirm each substitution any more; i.e. the :s_c flag is *not* kept! The documentation of g and :s_ explicitly state that they Keep the flags from the previous substitute command. Likewise, answering (l)ast omits a given :s_g flag on repetition. The problem is that the static flags do_all and do_ask are modified by the answers, and the modified answers are then reused on repetition, whereas the original ones should be restored in that case. From do_sub() : static int do_all = FALSE; /* do multiple substitutions per line */ static intdo_ask = FALSE; /* ask for confirmation */ [...] if (typed == 'l') { /* last: replace and then stop */ do_all = FALSE; line2 = lnum; break; } if (typed == 'a') { do_ask = FALSE; break; } Note: This was originally raised on Stack Overflow: http://stackoverflow.com/questions/3450/why-vim-does-not-preserve - -c- flag-when-g-used I understand this problem. I think this should be corrected. So, I wrote a patch. Please confirm this. Thanks. I can confirm that this fixes both reported problems. ? - -- regards, ingo -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.17 (MingW32) iQEcBAEBAgAGBQJVRzhvAAoJEA7ziXlAzQ/vmQEH/Ax7zP3oTc+4YZxukNrgU0aB F68V01Pn3+m2EFE5n+5jyAY3HXZG6wgzXqFga71+rE7HoqJMtPY6/WPoT8Wr0y0n +82JwkV0v+9JBYiywEGliTohKWMdepYQc4EHOsEI+dosiP9YoKvREU+tumZVQ5KL UdiKVUkZd3xXsyv7VX4bF+6/sS6KBZ+umnnsFagrNddPD1IsCXBQHoLxYWTHTo0z iTg/B7yOFhPtQII4WjExWzPon8L17TVgrgi1BmWC/xudlP8yP/1BRxONCJzbDfdb IaJedmceMxsO9/SjFcdXNK3a+DgnF/GqVBLpXSL2BUUNihhUOxeZr7FRk/gC/U4= =Z94K -END PGP SIGNATURE- -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: BUG: :substitute answers (a)ll / (l)ast affect c / g flags on repetition with g and :
Hirohito Higashi wrote: Hello Ingo! 2015/5/3(Sun) 4:46:50 UTC+9 Ingo Karkat: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello Vim developers, if you do a :substitute/foo/bar/c and then choose (a)ll as the answer, a repeat of the substitution via g or : does not confirm each substitution any more; i.e. the :s_c flag is *not* kept! The documentation of g and :s_ explicitly state that they Keep the flags from the previous substitute command. Likewise, answering (l)ast omits a given :s_g flag on repetition. The problem is that the static flags do_all and do_ask are modified by the answers, and the modified answers are then reused on repetition, whereas the original ones should be restored in that case. From do_sub() : static int do_all = FALSE; /* do multiple substitutions per line */ static int do_ask = FALSE; /* ask for confirmation */ [...] if (typed == 'l') { /* last: replace and then stop */ do_all = FALSE; line2 = lnum; break; } if (typed == 'a') { do_ask = FALSE; break; } Note: This was originally raised on Stack Overflow: http://stackoverflow.com/questions/3450/why-vim-does-not-preserve-c- flag-when-g-used I understand this problem. I think this should be corrected. So, I wrote a patch. Please confirm this. Thanks! -- Shift happens. -- Doppler /// Bram Moolenaar -- b...@moolenaar.net -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: BUG: :substitute answers (a)ll / (l)ast affect c / g flags on repetition with g and :
Hello Ingo! 2015/5/3(Sun) 4:46:50 UTC+9 Ingo Karkat: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello Vim developers, if you do a :substitute/foo/bar/c and then choose (a)ll as the answer, a repeat of the substitution via g or : does not confirm each substitution any more; i.e. the :s_c flag is *not* kept! The documentation of g and :s_ explicitly state that they Keep the flags from the previous substitute command. Likewise, answering (l)ast omits a given :s_g flag on repetition. The problem is that the static flags do_all and do_ask are modified by the answers, and the modified answers are then reused on repetition, whereas the original ones should be restored in that case. From do_sub() : static intdo_all = FALSE; /* do multiple substitutions per line */ static intdo_ask = FALSE; /* ask for confirmation */ [...] if (typed == 'l') { /* last: replace and then stop */ do_all = FALSE; line2 = lnum; break; } if (typed == 'a') { do_ask = FALSE; break; } Note: This was originally raised on Stack Overflow: http://stackoverflow.com/questions/3450/why-vim-does-not-preserve-c- flag-when-g-used I understand this problem. I think this should be corrected. So, I wrote a patch. Please confirm this. Thanks. Best regards, Hirohito Higashi (a.k.a h_east) -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. diff --git a/src/ex_cmds.c b/src/ex_cmds.c --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -4279,6 +4279,8 @@ static int do_list = FALSE; /* list last line with subs. */ static int do_number = FALSE; /* list last line with line nr*/ static int do_ic = 0; /* ignore case flag */ +int save_do_all; /* remember user specified 'g' flag */ +int save_do_ask; /* remember user specified 'c' flag */ char_u *pat = NULL, *sub = NULL; /* init for GCC */ int delimiter; int sublen; @@ -4514,6 +4516,9 @@ if (do_count) do_ask = FALSE; +save_do_all = do_all; +save_do_ask = do_ask; + /* * check for a trailing count */ @@ -5327,6 +5332,9 @@ #endif vim_regfree(regmatch.regprog); + +do_all = save_do_all; +do_ask = save_do_ask; } /*