vim-patch:8.2.4343: when reloading not all properties are detected

Problem:    When reloading not all properties are detected.
Solution:   Add the "edit" value to v:fcs_choice. (Rob Pilling, closes vim/vim#9579)
8196e94a8b

Cherry-pick some test changes from patch 8.1.1826.
This commit is contained in:
zeertzjq
2022-02-14 11:35:25 +08:00
parent 5d6bef0f6e
commit 5220891571
8 changed files with 216 additions and 42 deletions

View File

@@ -11,6 +11,11 @@ describe('file changed dialog', function()
clear()
meths.ui_attach(80, 24, {})
meths.set_option('autoread', false)
meths.set_option('fsync', true)
end)
it('works', function()
if helpers.pending_win32(pending) then return end
source([[
func Test_file_changed_dialog()
au! FileChangedShell
@@ -66,11 +71,61 @@ describe('file changed dialog', function()
call delete('Xchanged_d')
endfunc
]])
end)
it('works', function()
if helpers.pending_win32(pending) then return end
call('Test_file_changed_dialog')
expected_empty()
end)
it('works with FileChangedShell', function()
source([[
func Test_FileChangedShell_edit_dialog()
new Xchanged_r
call setline(1, 'reload this')
set fileformat=unix
silent write " Use :silent to prevent a hit-enter prompt
" File format changed, reload (content only) via prompt
augroup testreload
au!
au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'ask'
augroup END
call assert_equal(&fileformat, 'unix')
sleep 10m " make the test less flaky in Nvim
call writefile(["line1\r", "line2\r"], 'Xchanged_r')
let g:reason = ''
call nvim_input('L') " load file content only
checktime
call assert_equal('changed', g:reason)
call assert_equal(&fileformat, 'unix')
call assert_equal("line1\r", getline(1))
call assert_equal("line2\r", getline(2))
%s/\r
silent write " Use :silent to prevent a hit-enter prompt
" File format changed, reload (file and options) via prompt
augroup testreload
au!
au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'ask'
augroup END
call assert_equal(&fileformat, 'unix')
sleep 10m " make the test less flaky in Nvim
call writefile(["line1\r", "line2\r"], 'Xchanged_r')
let g:reason = ''
call nvim_input('a') " load file content and options
checktime
call assert_equal('changed', g:reason)
call assert_equal(&fileformat, 'dos')
call assert_equal("line1", getline(1))
call assert_equal("line2", getline(2))
set fileformat=unix
silent write " Use :silent to prevent a hit-enter prompt
au! testreload
bwipe!
call delete(undofile('Xchanged_r'))
call delete('Xchanged_r')
endfunc
]])
call('Test_FileChangedShell_edit_dialog')
expected_empty()
end)
end)