On Di, 14 Jan 2014, Bram Moolenaar wrote:
> Patch 7.4.150
> Problem: :keeppatterns is not respected for :s.
> Solution: Check the keeppatterns flag. (Yasuhiro Matsumoto)
> Files: src/search.c, src/testdir/test14.in, src/testdir/test14.ok
I think, we might also want to keep the offset. Here is a patch,
including a test.
Best,
Christian
--
Die Liebe allein versteht das Geheimnis, andere zu beschenken und
dabei selbst reich zu werden.
-- Clemens von Brentano
--
--
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/groups/opt_out.
diff --git a/src/search.c b/src/search.c
--- a/src/search.c
+++ b/src/search.c
@@ -1200,36 +1200,39 @@
dircp = p; /* remember where we put the NUL */
*p++ = NUL;
}
- spats[0].off.line = FALSE;
- spats[0].off.end = FALSE;
- spats[0].off.off = 0;
- /*
- * Check for a line offset or a character offset.
- * For get_address (echo off) we don't check for a character
- * offset, because it is meaningless and the 's' could be a
- * substitute command.
- */
- if (*p == '+' || *p == '-' || VIM_ISDIGIT(*p))
- spats[0].off.line = TRUE;
- else if ((options & SEARCH_OPT) &&
- (*p == 'e' || *p == 's' || *p == 'b'))
+ if (!cmdmod.keeppatterns)
{
- if (*p == 'e') /* end */
- spats[0].off.end = SEARCH_END;
- ++p;
- }
- if (VIM_ISDIGIT(*p) || *p == '+' || *p == '-') /* got an offset */
- {
- /* 'nr' or '+nr' or '-nr' */
- if (VIM_ISDIGIT(*p) || VIM_ISDIGIT(*(p + 1)))
- spats[0].off.off = atol((char *)p);
- else if (*p == '-') /* single '-' */
- spats[0].off.off = -1;
- else /* single '+' */
- spats[0].off.off = 1;
- ++p;
- while (VIM_ISDIGIT(*p)) /* skip number */
+ spats[0].off.line = FALSE;
+ spats[0].off.end = FALSE;
+ spats[0].off.off = 0;
+ /*
+ * Check for a line offset or a character offset.
+ * For get_address (echo off) we don't check for a character
+ * offset, because it is meaningless and the 's' could be a
+ * substitute command.
+ */
+ if (*p == '+' || *p == '-' || VIM_ISDIGIT(*p))
+ spats[0].off.line = TRUE;
+ else if ((options & SEARCH_OPT) &&
+ (*p == 'e' || *p == 's' || *p == 'b'))
+ {
+ if (*p == 'e') /* end */
+ spats[0].off.end = SEARCH_END;
++p;
+ }
+ if (VIM_ISDIGIT(*p) || *p == '+' || *p == '-') /* got an offset */
+ {
+ /* 'nr' or '+nr' or '-nr' */
+ if (VIM_ISDIGIT(*p) || VIM_ISDIGIT(*(p + 1)))
+ spats[0].off.off = atol((char *)p);
+ else if (*p == '-') /* single '-' */
+ spats[0].off.off = -1;
+ else /* single '+' */
+ spats[0].off.off = 1;
+ ++p;
+ while (VIM_ISDIGIT(*p)) /* skip number */
+ ++p;
+ }
}
/* compute length of search command for get_address() */
diff --git a/src/testdir/test14.in b/src/testdir/test14.in
--- a/src/testdir/test14.in
+++ b/src/testdir/test14.in
@@ -3,6 +3,7 @@
Also test for ^Vxff and ^Vo123 in Insert mode.
Also test "[m", "]m", "[M" and "]M"
Also test search()
+Also test :keeppatterns
STARTTEST
:so small.vim
@@ -56,7 +57,10 @@
:$put =@/
/^substitute
Y:$put =@0
-:/^search()/,$w >>test.out
+/bar /e
+:$put =@0
+-:keeppatterns /xyz
+0dn:/^search()/,$w >>test.out
:qa!
ENDTEST
diff --git a/src/testdir/test14.ok b/src/testdir/test14.ok
--- a/src/testdir/test14.ok
+++ b/src/testdir/test14.ok
@@ -23,3 +23,4 @@
foo
^substitute
substitute bar xyz
+xyz