From 7519af4f0fb54f4ef8b48ec4f18036069f18bf62 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 25 Feb 2022 00:13:25 +0000 Subject: [PATCH] vim-patch:8.2.4438: crash on exit when using cmdline window Problem: Crash on exit when using cmdline window. Solution: Reset "cmdwin_type" before exiting. (closes vim/vim#9817) https://github.com/vim/vim/commit/ca0c1caa36823ea8e61184268d7337e79995352f Bram also went with the cmdwin_type = 0 solution, but putting it in read_error_exit isn't ideal and only fixes one specific variant of the bug, so don't port that change. Port the test only, but skip it as Nvim does not exit after stdin is exhausted. Using -es instead does exit, but read_error_exit does not run preserve_exit in that case, and does not have issues exiting even without resetting cmdwin_type. Note that the test has problems and is fixed in later patches. --- src/nvim/testdir/test_exit.vim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/nvim/testdir/test_exit.vim b/src/nvim/testdir/test_exit.vim index bd3e9eb4d4..1d3722c718 100644 --- a/src/nvim/testdir/test_exit.vim +++ b/src/nvim/testdir/test_exit.vim @@ -1,6 +1,7 @@ " Tests for exiting Vim. source shared.vim +source check.vim func Test_exiting() let after =<< trim [CODE] @@ -109,4 +110,21 @@ func Test_exit_code() call delete('Xtestout') endfunc +func Test_exit_error_reading_input() + throw 'Skipped: Nvim does not exit after stdin is read' + + CheckNotGui + + call writefile([":au VimLeave * call writefile(['l = ' .. v:exiting], 'Xtestout')", ":tabnew\q:"], 'Xscript') + + " Nvim requires "-s -" to read stdin as Normal mode input + " if RunVim([], [], '< Xscript') + if RunVim([], [], '-s - < Xscript') + call assert_equal(['l = 1'], readfile('Xtestout')) + endif + call delete('Xscript') + call delete('Xtestout') +endfun + + " vim: shiftwidth=2 sts=2 expandtab