robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3 4local describe , it , before_each , after_each =t . describe , t . it , t . before_each , t . after_each 5local clear =n . clear 6local command =n . command 7local eq =t . eq 8local fn =n . fn 9local rmdir =n . rmdir 10local mkdir =t . mkdir 11 12describe ( ':file' , function () 13local swapdir =vim . uv . cwd () .. '/Xtest-file_spec' 14before_each ( function () 15clear () 16rmdir ( swapdir ) 17mkdir ( swapdir ) 18end ) 19after_each ( function () 20command ( '%bwipeout!' ) 21rmdir ( swapdir ) 22end ) 23 24it ( 'rename does not lose swapfile #6487' , function () 25local testfile ='test-file_spec' 26local testfile_renamed =testfile .. '-renamed' 27-- Note: `set swapfile` *must* go after `set directory`: otherwise it may 28-- attempt to create a swapfile in different directory. 29command ( 'set directory^=' .. swapdir .. '//' ) 30command ( 'set swapfile fileformat=unix undolevels=-1' ) 31 32command ( 'edit! ' .. testfile ) 33-- Before #6487 this gave "E301: Oops, lost the swap file !!!" on Windows. 34command ( 'file ' .. testfile_renamed ) 35eq ( testfile_renamed .. '.swp' , string . match ( fn . execute ( 'swapname' ), '[^%%]+$' )) 36end ) 37end )