Patch 8.1.2236

21 views
Skip to first unread message

Bram Moolenaar

unread,
Oct 30, 2019, 11:39:30 PM10/30/19
to vim...@googlegroups.com

Patch 8.1.2236
Problem: Ml_get error if pattern matches beyond last line.
Solution: Adjust position if needed. (Christian Brabandt, closes #5139)
Files: src/ex_cmds.c, src/testdir/test_substitute.vim


*** ../vim-8.1.2235/src/ex_cmds.c 2019-10-26 12:22:58.712730053 +0200
--- src/ex_cmds.c 2019-10-31 04:12:37.961027612 +0100
***************
*** 3947,3952 ****
--- 3947,3957 ----
VIM_CLEAR(sub_firstline);
}

+ // Match might be after the last line for "\n\zs" matching at
+ // the end of the last line.
+ if (lnum > curbuf->b_ml.ml_line_count)
+ break;
+
if (sub_firstline == NULL)
{
sub_firstline = vim_strsave(ml_get(sub_firstlnum));
*** ../vim-8.1.2235/src/testdir/test_substitute.vim 2019-09-07 19:05:02.341280926 +0200
--- src/testdir/test_substitute.vim 2019-10-31 04:35:14.566693602 +0100
***************
*** 413,418 ****
--- 413,419 ----
for t in a:tests
let start = line('.') + 1
let end = start + len(t[2]) - 1
+ " TODO: why is there a one second delay the first time we get here?
exe "normal o" . t[0]
call cursor(start, 1)
exe t[1]
***************
*** 716,718 ****
--- 717,728 ----

close!
endfunc
+
+ func Test_sub_beyond_end()
+ new
+ call setline(1, '#')
+ let @/ = '^#\n\zs'
+ s///e
+ call assert_equal('#', getline(1))
+ bwipe!
+ endfunc
*** ../vim-8.1.2235/src/version.c 2019-10-31 03:21:21.121403678 +0100
--- src/version.c 2019-10-31 04:10:59.513546788 +0100
***************
*** 743,744 ****
--- 743,746 ----
{ /* Add new patch number below this line */
+ /**/
+ 2236,
/**/

--
"How is your new girlfriend?"
"90-60-90 man!"
"What, pale purple?"

/// Bram Moolenaar -- Br...@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 ///

Christian Brabandt

unread,
Oct 31, 2019, 5:05:16 AM10/31/19
to vim...@googlegroups.com

On Do, 31 Okt 2019, Bram Moolenaar wrote:

> + func Test_sub_beyond_end()
> + new
> + call setline(1, '#')
> + let @/ = '^#\n\zs'
> + s///e
> + call assert_equal('#', getline(1))
> + bwipe!
> + endfunc

Did this test fail before 8.1.2236? I tried the same, but
for some reason I couldn't get it to fail, unless I gave the substitute
command on the command line. I then tried to simplify the test like
this:

diff --git a/src/testdir/test_substitute.vim b/src/testdir/test_substitute.vim
index 8a8e7ab4f..24158b186 100644
--- a/src/testdir/test_substitute.vim
+++ b/src/testdir/test_substitute.vim
@@ -716,3 +716,10 @@ one two

close!
endfunc
+
+func Test_substitute_endofline()
+ new
+ "call assert_fails(':s/\n\zs//', 'E486')
+ :s/\n\zs//
+ bw!
+endfunc


Which works now, but before 8.1.2236 it hangs, because the ml_get_error
requires to press enter a few times.

Tried the assert_fails(), but that does not throw E486 now, so the test
now fails. Anyhow, I was just curious. I guess nothing to be done here.

Mit freundlichen Grüßen
Christian
--
"Weißt du, was ich an Euch Emanzen so bewundere?"
Emanze: "Keine Ahnung"
"Euer Selbstbewußtsein. Das gleicht die meisten anderen Nachteile wieder aus."

Bram Moolenaar

unread,
Oct 31, 2019, 2:58:18 PM10/31/19
to vim...@googlegroups.com, Christian Brabandt

Christian wrote:

> On Do, 31 Okt 2019, Bram Moolenaar wrote:
>
> > + func Test_sub_beyond_end()
> > + new
> > + call setline(1, '#')
> > + let @/ = '^#\n\zs'
> > + s///e
> > + call assert_equal('#', getline(1))
> > + bwipe!
> > + endfunc
>
> Did this test fail before 8.1.2236?

Yes. Just tried again, without the fix the test fails (or hangs).

> I tried the same, but for some reason I couldn't get it to fail,
> unless I gave the substitute command on the command line. I then tried
> to simplify the test like this:
>
> diff --git a/src/testdir/test_substitute.vim b/src/testdir/test_substitute.vim
> index 8a8e7ab4f..24158b186 100644
> --- a/src/testdir/test_substitute.vim
> +++ b/src/testdir/test_substitute.vim
> @@ -716,3 +716,10 @@ one two
>
> close!
> endfunc
> +
> +func Test_substitute_endofline()
> + new
> + "call assert_fails(':s/\n\zs//', 'E486')
> + :s/\n\zs//
> + bw!
> +endfunc
>
>
> Which works now, but before 8.1.2236 it hangs, because the ml_get_error
> requires to press enter a few times.
>
> Tried the assert_fails(), but that does not throw E486 now, so the test
> now fails. Anyhow, I was just curious. I guess nothing to be done here.

--
hundred-and-one symptoms of being an internet addict:
12. You turn off your Wifi and get this awful empty feeling, like you just
pulled the plug on a loved one.
Reply all
Reply to author
Forward
0 new messages