1
0
forked from aniani/vim

patch 9.1.0677: :keepp does not retain the substitute pattern

Problem:  :keeppatterns does not retain the substitute pattern
          for a :s command
Solution: preserve the last substitute pattern when used with the
          :keeppatterns command modifier (Gregory Anders)

closes: #15497

Signed-off-by: Gregory Anders <greg@gpanders.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Gregory Anders
2024-08-15 22:04:22 +02:00
committed by Christian Brabandt
parent 12cb1d1326
commit 3b59be4ed8
5 changed files with 19 additions and 10 deletions

View File

@@ -806,7 +806,7 @@ func Test_replace_keeppatterns()
a
foobar
substitute foo asdf
substitute foo asdf foo
one two
.
@@ -815,21 +815,26 @@ one two
/^substitute
s/foo/bar/
call assert_equal('foo', @/)
call assert_equal('substitute bar asdf', getline('.'))
call assert_equal('substitute bar asdf foo', getline('.'))
/^substitute
keeppatterns s/asdf/xyz/
call assert_equal('^substitute', @/)
call assert_equal('substitute bar xyz', getline('.'))
call assert_equal('substitute bar xyz foo', getline('.'))
/^substitute
&
call assert_equal('^substitute', @/)
call assert_equal('substitute bar xyz bar', getline('.'))
exe "normal /bar /e\<CR>"
call assert_equal(15, col('.'))
normal -
keeppatterns /xyz
call assert_equal('bar ', @/)
call assert_equal('substitute bar xyz', getline('.'))
call assert_equal('substitute bar xyz bar', getline('.'))
exe "normal 0dn"
call assert_equal('xyz', getline('.'))
call assert_equal('xyz bar', getline('.'))
close!
endfunc