diff --git a/test/functional/fixtures/zip/browser.zip b/test/functional/fixtures/zip/browser.zip index 24e2716422..58288753e6 100644 Binary files a/test/functional/fixtures/zip/browser.zip and b/test/functional/fixtures/zip/browser.zip differ diff --git a/test/functional/plugin/zip_spec.lua b/test/functional/plugin/zip_spec.lua index 1b2023083b..5e969bc4f9 100644 --- a/test/functional/plugin/zip_spec.lua +++ b/test/functional/plugin/zip_spec.lua @@ -136,10 +136,15 @@ describe('nvim.zip', function() edit(archive) - eq( - { 'folder/', 'inner.zip', '../escape.txt', '/absolute.txt', 'crlf.txt', 'noeol.txt' }, - lines() - ) + eq({ + 'folder/', + 'inner.zip', + '../escape.txt', + '/absolute.txt', + 'crlf.txt', + 'noeol.txt', + 'names/', + }, lines()) eq('zip', api.nvim_get_option_value('filetype', { buf = 0 })) eq(true, exec_capture('syntax list zipDirectory'):find('zipDirectory', 1, true) ~= nil) @@ -271,6 +276,53 @@ describe('nvim.zip', function() end end) + it('lists and opens entries with difficult names', function() + t.skip(t.is_os('win'), 'N/A: Windows filenames cannot contain these characters') + local archive = vim.fs.joinpath(root, 'browser.zip') + copy_fixture(vim.fs.joinpath(fixtures, 'browser.zip'), archive) + clear_zip() + + local names = { + 'space name.txt', + 'two spaces.txt', + ' leading.txt', + 'trailing .txt', + [[back\slash.txt]], + [[single'quote.txt]], + 'double"quote.txt', + 'dollar$name.txt', + 'backtick`name.txt', + 'semi;name.txt', + 'pipe|name.txt', + 'amp&name.txt', + 'paren(name).txt', + 'bang!name.txt', + 'hash#name.txt', + 'percent%name.txt', + 'star*.txt', + 'question?.txt', + '[bracket].txt', + '-dash.txt', + } + + edit(archive) + api.nvim_win_set_cursor(0, { line_of('names/'), 0 }) + feed('') + poke_eventloop() + eq(names, lines()) + + api.nvim_win_set_cursor(0, { line_of('star*.txt'), 0 }) + feed('') + poke_eventloop() + eq(('zipfile://%s::names/star*.txt'):format(archive), api.nvim_buf_get_name(0)) + eq({ 'content of star*.txt' }, lines()) + + for _, name in ipairs(names) do + edit(('zipfile://%s::names/%s'):format(archive, name)) + eq({ 'content of ' .. name }, lines()) + end + end) + it('keeps a leading dash in a path from becoming a backend option', function() local archive = vim.fs.joinpath(root, 'poc.zip') copy_fixture(vim.fs.joinpath(old_samples, 'poc.zip'), archive)