fix(test): :CP is now a valid command
This commit is contained in:
parent
77aa5dd4c4
commit
a1aa4ccbf9
2 changed files with 8 additions and 4 deletions
|
|
@ -75,10 +75,11 @@ function M.restore_layout(state, tile_fn)
|
||||||
local source_file
|
local source_file
|
||||||
if source_files ~= '' then
|
if source_files ~= '' then
|
||||||
local files = vim.split(source_files, '\n')
|
local files = vim.split(source_files, '\n')
|
||||||
local valid_extensions = vim.tbl_keys(constants.filetype_to_language)
|
-- Prefer known extensions first, but accept any extension
|
||||||
|
local known_extensions = vim.tbl_keys(constants.filetype_to_language)
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
local ext = vim.fn.fnamemodify(file, ':e')
|
local ext = vim.fn.fnamemodify(file, ':e')
|
||||||
if vim.tbl_contains(valid_extensions, ext) then
|
if vim.tbl_contains(known_extensions, ext) then
|
||||||
source_file = file
|
source_file = file
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ describe('cp command parsing', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('empty arguments', function()
|
describe('empty arguments', function()
|
||||||
it('logs error for no arguments', function()
|
it('attempts file state restoration for no arguments', function()
|
||||||
local opts = { fargs = {} }
|
local opts = { fargs = {} }
|
||||||
|
|
||||||
cp.handle_command(opts)
|
cp.handle_command(opts)
|
||||||
|
|
@ -40,7 +40,10 @@ describe('cp command parsing', function()
|
||||||
assert.is_true(#logged_messages > 0)
|
assert.is_true(#logged_messages > 0)
|
||||||
local error_logged = false
|
local error_logged = false
|
||||||
for _, log_entry in ipairs(logged_messages) do
|
for _, log_entry in ipairs(logged_messages) do
|
||||||
if log_entry.level == vim.log.levels.ERROR and log_entry.msg:match('Usage:') then
|
if
|
||||||
|
log_entry.level == vim.log.levels.ERROR
|
||||||
|
and log_entry.msg:match('No file is currently open')
|
||||||
|
then
|
||||||
error_logged = true
|
error_logged = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue