neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

file_spec.lua (1092B)


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