diff src/testdir/test_search_stat.vim @ 31875:244d4a84c546 v9.0.1270

patch 9.0.1270: crash when using search stat in narrow screen Commit: https://github.com/vim/vim/commit/a7d36b732070944aab614944075ec0b409311482 Author: zeertzjq <zeertzjq@outlook.com> Date: Tue Jan 31 21:13:38 2023 +0000 patch 9.0.1270: crash when using search stat in narrow screen Problem: Crash when using search stat in narrow screen. Solution: Check length of message. (closes https://github.com/vim/vim/issues/11921)
author Bram Moolenaar <Bram@vim.org>
date Tue, 31 Jan 2023 22:15:04 +0100
parents ae10b91ac6b3
children 9ba8d1a8fecd
line wrap: on
line diff
--- a/src/testdir/test_search_stat.vim
+++ b/src/testdir/test_search_stat.vim
@@ -270,6 +270,29 @@ func Test_searchcount_fails()
   call assert_fails('echo searchcount({"pos" : [1, 2, []]})', 'E745:')
 endfunc
 
+func Test_search_stat_narrow_screen()
+  " This used to crash Vim
+  let save_columns = &columns
+  try
+    let after =<< trim [CODE]
+      set laststatus=2
+      set columns=16
+      set shortmess-=S showcmd
+      call setline(1, 'abc')
+      call feedkeys("/abc\<CR>:quit!\<CR>")
+      autocmd VimLeavePre * call writefile(["done"], "Xdone")
+    [CODE]
+
+    if !RunVim([], after, '--clean')
+      return
+    endif
+    call assert_equal("done", readfile("Xdone")[0])
+    call delete('Xdone')
+  finally
+    let &columns = save_columns
+  endtry
+endfunc
+
 func Test_searchcount_in_statusline()
   CheckScreendump