patch 8.2.4685: when a swap file is found for a popup there is no dialog
Problem: When a swap file is found for a popup there is no dialog and the
buffer is loaded anyway.
Solution: Silently load the buffer read-only. (closes #10073)
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 08f45ae..b91689e 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -2775,6 +2775,26 @@
call delete('XsomeFile')
endfunc
+func Test_popupwin_buffer_with_swapfile()
+ call writefile(['some text', 'in a buffer'], 'XopenFile')
+ call writefile([''], '.XopenFile.swp')
+ let g:ignoreSwapExists = 1
+
+ let bufnr = bufadd('XopenFile')
+ call assert_equal(0, bufloaded(bufnr))
+ let winid = popup_create(bufnr, {'hidden': 1})
+ call assert_equal(1, bufloaded(bufnr))
+ call popup_close(winid)
+
+ exe 'buffer ' .. bufnr
+ call assert_equal(1, &readonly)
+ bwipe!
+
+ call delete('XopenFile')
+ call delete('.XopenFile.swp')
+ unlet g:ignoreSwapExists
+endfunc
+
func Test_popupwin_terminal_buffer()
CheckFeature terminal
CheckUnix