1
0
forked from aniani/vim

patch 9.1.0112: Remove undo information, when cleaning quickfix buffer

Problem:  When the quickfix buffer has been modified an autocommand
          may invalidate the undo stack (kawarimidoll)
Solution: When clearing the quickfix buffer, also wipe the undo stack

fixes: #13905
closes: #13928

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2024-02-15 20:15:04 +01:00
parent d00fb4b3a2
commit f0d3d4a426
3 changed files with 40 additions and 0 deletions

View File

@@ -4413,4 +4413,32 @@ func Test_autocmd_shortmess()
delfunc SetupVimTest_shm
endfunc
func Test_autocmd_invalidates_undo_on_textchanged()
CheckRunVimInTerminal
let script =<< trim END
set hidden
" create quickfix list (at least 2 lines to move line)
vimgrep /u/j %
" enter quickfix window
cwindow
" set modifiable
setlocal modifiable
" set autocmd to clear quickfix list
autocmd! TextChanged <buffer> call setqflist([])
" move line
move+1
END
call writefile(script, 'XTest_autocmd_invalidates_undo_on_textchanged', 'D')
let buf = RunVimInTerminal('XTest_autocmd_invalidates_undo_on_textchanged', {'rows': 20})
call term_sendkeys(buf, ":so %\<cr>")
call term_sendkeys(buf, "G")
call WaitForAssert({-> assert_match('^XTest_autocmd_invalidates_undo_on_textchanged\s*$', term_getline(buf, 20))}, 1000)
call StopVimInTerminal(buf)
endfunc
" vim: shiftwidth=2 sts=2 expandtab