2017-04-09 16:38:20 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2023-04-04 12:59:06 -07:00
|
|
|
local luv = require('luv')
|
2017-04-09 16:38:20 -07:00
|
|
|
local clear = helpers.clear
|
|
|
|
local command = helpers.command
|
|
|
|
local eq = helpers.eq
|
|
|
|
local funcs = helpers.funcs
|
|
|
|
local rmdir = helpers.rmdir
|
2023-04-04 12:59:06 -07:00
|
|
|
local mkdir = helpers.mkdir
|
2017-04-09 16:38:20 -07:00
|
|
|
|
|
|
|
describe(':file', function()
|
2024-01-02 18:09:18 -07:00
|
|
|
local swapdir = luv.cwd() .. '/Xtest-file_spec'
|
2017-04-09 16:38:20 -07:00
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
rmdir(swapdir)
|
2023-04-04 12:59:06 -07:00
|
|
|
mkdir(swapdir)
|
2017-04-09 16:38:20 -07:00
|
|
|
end)
|
|
|
|
after_each(function()
|
|
|
|
command('%bwipeout!')
|
|
|
|
rmdir(swapdir)
|
|
|
|
end)
|
|
|
|
|
2024-01-02 18:09:18 -07:00
|
|
|
it('rename does not lose swapfile #6487', function()
|
2017-04-09 16:38:20 -07:00
|
|
|
local testfile = 'test-file_spec'
|
2024-01-02 18:09:18 -07:00
|
|
|
local testfile_renamed = testfile .. '-renamed'
|
2017-04-09 16:38:20 -07:00
|
|
|
-- Note: `set swapfile` *must* go after `set directory`: otherwise it may
|
|
|
|
-- attempt to create a swapfile in different directory.
|
2024-01-02 18:09:18 -07:00
|
|
|
command('set directory^=' .. swapdir .. '//')
|
2017-04-09 16:38:20 -07:00
|
|
|
command('set swapfile fileformat=unix undolevels=-1')
|
|
|
|
|
2024-01-02 18:09:18 -07:00
|
|
|
command('edit! ' .. testfile)
|
2017-04-09 16:38:20 -07:00
|
|
|
-- Before #6487 this gave "E301: Oops, lost the swap file !!!" on Windows.
|
2024-01-02 18:09:18 -07:00
|
|
|
command('file ' .. testfile_renamed)
|
|
|
|
eq(testfile_renamed .. '.swp', string.match(funcs.execute('swapname'), '[^%%]+$'))
|
2017-04-09 16:38:20 -07:00
|
|
|
end)
|
|
|
|
end)
|