From dc466f9a63ede5e2bbddc33688c0c972abfe9a52 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 23 Jan 2024 06:51:10 +0800 Subject: vim-patch:9.1.0043: ml_get: invalid lnum when :s replaces visual selection (#27140) Problem: ml_get: invalid lnum when :s replaces visual selection (@ropery) Solution: substitute may decrement the number of lines in a buffer, so validate, that the bottom lines of the visual selection stays within the max buffer line fixes: vim/vim#13890 closes: vim/vim#13892 https://github.com/vim/vim/commit/7c71db3a58f658b4329b82ab603efa928d17bdbc Co-authored-by: Christian Brabandt --- test/old/testdir/test_visual.vim | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/old/testdir/test_visual.vim b/test/old/testdir/test_visual.vim index b09078352e..983f07a375 100644 --- a/test/old/testdir/test_visual.vim +++ b/test/old/testdir/test_visual.vim @@ -1626,4 +1626,12 @@ func Test_visual_drag_out_of_window() bwipe! endfunc +func Test_visual_substitute_visual() + new + call setline(1, ['one', 'two', 'three']) + call feedkeys("Gk\j$:s/\\%V\\_.*\\%V/foobar\", 'tx') + call assert_equal(['one', 'foobar'], getline(1, '$')) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit