diff src/testdir/test_substitute.vim @ 29042:e150d0e4701f v8.2.5043

patch 8.2.5043: can open a cmdline window from a substitute expression Commit: https://github.com/vim/vim/commit/71223e2db87c2bf3b09aecb46266b56cda26191d Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 30 15:23:09 2022 +0100 patch 8.2.5043: can open a cmdline window from a substitute expression Problem: Can open a cmdline window from a substitute expression. Solution: Disallow opening a command line window when text or buffer is locked.
author Bram Moolenaar <Bram@vim.org>
date Mon, 30 May 2022 16:30:03 +0200
parents 48d74a5822eb
children 55ce8628cd9b
line wrap: on
line diff
--- a/src/testdir/test_substitute.vim
+++ b/src/testdir/test_substitute.vim
@@ -1035,6 +1035,31 @@ func Test_sub_undo_change()
   delfunc Repl
 endfunc
 
+" This was opening a command line window from the expression
+func Test_sub_open_cmdline_win()
+  " the error only happens in a very specific setup, run a new Vim instance to
+  " get a clean starting point.
+  let lines =<< trim [SCRIPT]
+    norm o0000000000000000000000000000000000000000000000000000
+    func Replace()
+      norm q/
+    endfunc
+    s/\%')/\=Replace()
+    redir >Xresult
+    messages
+    redir END
+    qall!
+  [SCRIPT]
+  call writefile(lines, 'Xscript')
+  if RunVim([], [], '-u NONE -S Xscript')
+    let messages = readfile('Xresult')
+    call assert_match('E565: Not allowed to change text or change window', messages[3])
+  endif
+
+  call delete('Xscript')
+  call delete('Xresult')
+endfunc
+
 " Test for the 2-letter and 3-letter :substitute commands
 func Test_substitute_short_cmd()
   new