diff src/testdir/test_substitute.vim @ 16716:5a541d459ef7 v8.1.1360

patch 8.1.1360: buffer left 'nomodifiable' after :substitute commit https://github.com/vim/vim/commit/80341bcd89764d96f87859a3aac8bc00aad1d762 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 20 20:34:51 2019 +0200 patch 8.1.1360: buffer left 'nomodifiable' after :substitute Problem: Buffer left 'nomodifiable' after :substitute. (Ingo Karkat) Solution: Save the value of 'modifiable' earlier' (Christian Brabandt, closes #4403)
author Bram Moolenaar <Bram@vim.org>
date Mon, 20 May 2019 20:45:06 +0200
parents 6ea3f93b4428
children f084f846442a
line wrap: on
line diff
--- a/src/testdir/test_substitute.vim
+++ b/src/testdir/test_substitute.vim
@@ -611,9 +611,24 @@ func Test_sub_cmd_8()
   set titlestring&
 endfunc
 
+func Test_sub_cmd_9()
+  new
+  let input = ['1 aaa', '2 aaa', '3 aaa']
+  call setline(1, input)
+  func Foo()
+    return submatch(0)
+  endfunc
+  %s/aaa/\=Foo()/gn
+  call assert_equal(input, getline(1, '$'))
+  call assert_equal(1, &modifiable)
+
+  delfunc Foo
+  bw!
+endfunc
+
 func Test_nocatch_sub_failure_handling()
   " normal error results in all replacements 
-  func! Foo()
+  func Foo()
     foobar
   endfunc
   new
@@ -649,6 +664,7 @@ func Test_nocatch_sub_failure_handling()
   call assert_equal(1, error_caught)
   call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3))
 
+  delfunc Foo
   bwipe!
 endfunc