mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 11:25:33 +00:00
oldfiles_spec: Add tests for ":filter ... oldfiles"
This commit is contained in:
@@ -4,6 +4,7 @@ local helpers = require('test.functional.helpers')(after_each)
|
|||||||
local buf, eq, feed_command = helpers.curbufmeths, helpers.eq, helpers.feed_command
|
local buf, eq, feed_command = helpers.curbufmeths, helpers.eq, helpers.feed_command
|
||||||
local feed, nvim_prog, wait = helpers.feed, helpers.nvim_prog, helpers.wait
|
local feed, nvim_prog, wait = helpers.feed, helpers.nvim_prog, helpers.wait
|
||||||
local ok, set_session, spawn = helpers.ok, helpers.set_session, helpers.spawn
|
local ok, set_session, spawn = helpers.ok, helpers.set_session, helpers.spawn
|
||||||
|
local eval = helpers.eval
|
||||||
|
|
||||||
local shada_file = 'Xtest.shada'
|
local shada_file = 'Xtest.shada'
|
||||||
|
|
||||||
@@ -42,6 +43,38 @@ describe(':oldfiles', function()
|
|||||||
Press ENTER or type command to continue^ |
|
Press ENTER or type command to continue^ |
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('can be filtered with :filter', function()
|
||||||
|
feed_command('edit file_one.txt')
|
||||||
|
local file1 = buf.get_name()
|
||||||
|
feed_command('edit file_two.txt')
|
||||||
|
local file2 = buf.get_name()
|
||||||
|
feed_command('edit another.txt')
|
||||||
|
local another = buf.get_name()
|
||||||
|
feed_command('wshada')
|
||||||
|
feed_command('rshada!')
|
||||||
|
|
||||||
|
local function get_oldfiles(cmd)
|
||||||
|
local t = eval([[split(execute(']]..cmd..[['), "\n")]])
|
||||||
|
for i, _ in ipairs(t) do
|
||||||
|
t[i] = t[i]:gsub('^%d+:%s+', '')
|
||||||
|
end
|
||||||
|
table.sort(t)
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
local oldfiles = get_oldfiles('oldfiles')
|
||||||
|
eq({another, file1, file2}, oldfiles)
|
||||||
|
|
||||||
|
oldfiles = get_oldfiles('filter file_ oldfiles')
|
||||||
|
eq({file1, file2}, oldfiles)
|
||||||
|
|
||||||
|
oldfiles = get_oldfiles('filter /another/ oldfiles')
|
||||||
|
eq({another}, oldfiles)
|
||||||
|
|
||||||
|
oldfiles = get_oldfiles('filter! file_ oldfiles')
|
||||||
|
eq({another}, oldfiles)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe(':browse oldfiles', function()
|
describe(':browse oldfiles', function()
|
||||||
|
|||||||
Reference in New Issue
Block a user