Am 2014-04-23 16:28, schrieb Bram Moolenaar:
Ingo Karkat wrote:
I've noticed a regression:
:s/.*/\="foo\nbar"/
This correctly replaces the current line with two lines containing
"foo"
and "bar", respectively. Now add the confirm flag, and accept the
replacement:
:s/.*/\="foo\nbar"/c
This replaces the current line with a single line containing
"foo^@bar"
(where ^@ is <Nul>). This is inconsistent and unexpected. Replacing
with
\r instead works (with and without the flag), and can be used as a
workaround.
Using the attached scriptlet, I've bisected this to the following
patch:
,----[ bad change ]----
| 7.3.225 "\n" in a substitute() inside ":s" not handled correctly
`----
The problem therefore can be seen in this and all following Vim
versions, verified up to the latest 7.4.258. (I've used a HUGE build
on
both Windows/x64 and Linux/x64.)
I cannot reproduce this problem.
I see the problem with vim-airline. I think, it is caused by the
evaluation of the statusline resetting reg_line_lbr when displaying the
confirmation message. Attached patch fixes this, but I think one should
also reset all the other internal static variables.
Best,
Christian
--
--
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 [email protected].
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
@@ -4844,6 +4844,8 @@ do_sub(eap)
msg_scroll = 0; /* truncate msg when
needed */
msg_no_more = TRUE;
+ /* Redrawing may cause statusline function to update reg_line_lbr */
+ regex_store_flags();
/* write message same highlighting as for
* wait_return */
smsg_attr(hl_attr(HLF_R),
@@ -4853,6 +4855,7 @@ do_sub(eap)
showruler(TRUE);
windgoto(msg_row, msg_col);
RedrawingDisabled = temp;
+ regex_restore_flags();
#ifdef USE_ON_FLY_SCROLL
dont_scroll = FALSE; /* allow scrolling here */
diff --git a/src/proto/regexp.pro b/src/proto/regexp.pro
--- a/src/proto/regexp.pro
+++ b/src/proto/regexp.pro
@@ -15,4 +15,6 @@ void vim_regfree __ARGS((regprog_T *prog
int vim_regexec __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
int vim_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
long vim_regexec_multi __ARGS((regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm));
+void regex_store_flags __ARGS((void));
+void regex_restore_flags __ARGS((void));
/* vim: set ft=c : */
diff --git a/src/regexp.c b/src/regexp.c
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -3585,6 +3585,7 @@ static buf_T *reg_buf;
static linenr_T reg_firstlnum;
static linenr_T reg_maxline;
static int reg_line_lbr; /* "\n" in string is line break */
+static int reg_line_lbr_save; /* saved reg_line_lbr_value */
/* Values for rs_state in regitem_T. */
typedef enum regstate_E
@@ -8087,3 +8088,17 @@ vim_regexec_multi(rmp, win, buf, lnum, c
{
return rmp->regprog->engine->regexec_multi(rmp, win, buf, lnum, col, tm);
}
+
+/* Save and restore static flags */
+ void
+regex_store_flags()
+{
+ /* What about the other flags? */
+ reg_line_lbr_save = reg_line_lbr;
+}
+
+ void
+regex_restore_flags()
+{
+ reg_line_lbr = reg_line_lbr_save;
+}