From b28683d25281847716ca0003cecedb3f3a34d089 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 16 Apr 2023 17:44:14 +0800 Subject: vim-patch:9.0.0947: invalid memory access in substitute with function (#23126) Problem: Invalid memory access in substitute with function that goes to another file. Solution: Check for text locked in CTRL-W gf. https://github.com/vim/vim/commit/cc762a48d42b579fb7bdec2c614636b830342dd5 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_substitute.vim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/old/testdir/test_substitute.vim b/test/old/testdir/test_substitute.vim index b2abbae168..f15ef122ec 100644 --- a/test/old/testdir/test_substitute.vim +++ b/test/old/testdir/test_substitute.vim @@ -1090,6 +1090,25 @@ func Test_sub_edit_scriptfile() bwipe! endfunc +" This was editing another file from the expression. +func Test_sub_expr_goto_other_file() + call writefile([''], 'Xfileone', 'D') + enew! + call setline(1, ['a', 'b', 'c', 'd', + \ 'Xfileone zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']) + + func g:SplitGotoFile() + exe "sil! norm 0\gf" + return '' + endfunc + + $ + s/\%')/\=g:SplitGotoFile() + + delfunc g:SplitGotoFile + bwipe! +endfunc + " Test for the 2-letter and 3-letter :substitute commands func Test_substitute_short_cmd() new -- cgit