2017-09-18 11:06:55 -07:00
|
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
|
|
|
local clear = helpers.clear
|
|
|
|
|
local eq = helpers.eq
|
|
|
|
|
local eval = helpers.eval
|
|
|
|
|
local command = helpers.command
|
2022-10-06 18:43:16 -07:00
|
|
|
|
local insert = helpers.insert
|
|
|
|
|
local feed = helpers.feed
|
2022-11-21 17:13:30 -07:00
|
|
|
|
local is_os = helpers.is_os
|
2017-09-18 11:06:55 -07:00
|
|
|
|
|
2017-10-01 15:24:19 -07:00
|
|
|
|
describe('path collapse', function()
|
2017-09-18 11:06:55 -07:00
|
|
|
|
local targetdir
|
|
|
|
|
local expected_path
|
|
|
|
|
|
|
|
|
|
local function join_path(...)
|
2022-11-21 17:13:30 -07:00
|
|
|
|
local pathsep = (is_os('win') and '\\' or '/')
|
2017-09-18 11:06:55 -07:00
|
|
|
|
return table.concat({...}, pathsep)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
|
targetdir = join_path('test', 'functional', 'fixtures')
|
2017-10-01 15:24:19 -07:00
|
|
|
|
clear()
|
|
|
|
|
command('edit '..join_path(targetdir, 'tty-test.c'))
|
|
|
|
|
expected_path = eval('expand("%:p")')
|
2017-09-18 11:06:55 -07:00
|
|
|
|
end)
|
|
|
|
|
|
2017-10-01 15:24:19 -07:00
|
|
|
|
it('with /./ segment #7117', function()
|
|
|
|
|
command('edit '..join_path(targetdir, '.', 'tty-test.c'))
|
|
|
|
|
eq(expected_path, eval('expand("%:p")'))
|
2017-09-18 11:06:55 -07:00
|
|
|
|
end)
|
|
|
|
|
|
2017-10-01 15:24:19 -07:00
|
|
|
|
it('with ./ prefix #7117', function()
|
|
|
|
|
command('edit '..join_path('.', targetdir, 'tty-test.c'))
|
|
|
|
|
eq(expected_path, eval('expand("%:p")'))
|
2017-09-18 11:06:55 -07:00
|
|
|
|
end)
|
|
|
|
|
|
2017-10-01 15:24:19 -07:00
|
|
|
|
it('with ./ prefix, after directory change #7117', function()
|
|
|
|
|
command('edit '..join_path('.', targetdir, 'tty-test.c'))
|
2017-09-18 11:06:55 -07:00
|
|
|
|
command('cd test')
|
2017-10-01 15:24:19 -07:00
|
|
|
|
eq(expected_path, eval('expand("%:p")'))
|
2017-09-18 11:06:55 -07:00
|
|
|
|
end)
|
|
|
|
|
|
2017-10-01 15:24:19 -07:00
|
|
|
|
it('with /../ segment #7117', function()
|
|
|
|
|
command('edit '..join_path(targetdir, '..', 'fixtures', 'tty-test.c'))
|
|
|
|
|
eq(expected_path, eval('expand("%:p")'))
|
2017-09-18 11:06:55 -07:00
|
|
|
|
end)
|
|
|
|
|
|
2017-10-01 15:24:19 -07:00
|
|
|
|
it('with ../ and different starting directory #7117', function()
|
2017-09-18 11:06:55 -07:00
|
|
|
|
command('cd test')
|
2017-10-01 15:24:19 -07:00
|
|
|
|
command('edit '..join_path('..', targetdir, 'tty-test.c'))
|
|
|
|
|
eq(expected_path, eval('expand("%:p")'))
|
2017-09-18 11:06:55 -07:00
|
|
|
|
end)
|
|
|
|
|
|
2017-10-01 15:24:19 -07:00
|
|
|
|
it('with ./../ and different starting directory #7117', function()
|
2017-09-18 11:06:55 -07:00
|
|
|
|
command('cd test')
|
2017-10-01 15:24:19 -07:00
|
|
|
|
command('edit '..join_path('.', '..', targetdir, 'tty-test.c'))
|
|
|
|
|
eq(expected_path, eval('expand("%:p")'))
|
2017-09-18 11:06:55 -07:00
|
|
|
|
end)
|
|
|
|
|
end)
|
2022-10-06 18:43:16 -07:00
|
|
|
|
|
|
|
|
|
describe('file search', function()
|
|
|
|
|
before_each(clear)
|
|
|
|
|
|
|
|
|
|
it('find multibyte file name in line #20517', function()
|
|
|
|
|
command('cd test/functional/fixtures')
|
|
|
|
|
insert('filename_with_unicode_ααα')
|
|
|
|
|
eq('', eval('expand("%")'))
|
|
|
|
|
feed('gf')
|
|
|
|
|
eq('filename_with_unicode_ααα', eval('expand("%:t")'))
|
|
|
|
|
end)
|
|
|
|
|
end)
|