2014-09-29 05:43:52 -07:00
|
|
|
-- Test if URLs are recognized as filenames by commands such as "gf". Here
|
|
|
|
-- we'll use `expand("<cfile>")` since "gf" would need to open the file.
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2014-09-29 05:43:52 -07:00
|
|
|
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
2017-04-08 14:12:26 -07:00
|
|
|
local feed_command, expect = helpers.feed_command, helpers.expect
|
2014-09-29 05:43:52 -07:00
|
|
|
|
|
|
|
describe('filename recognition', function()
|
|
|
|
setup(clear)
|
|
|
|
|
|
|
|
it('is working', function()
|
|
|
|
-- insert some lines containing URLs
|
|
|
|
insert([[
|
|
|
|
first test for URL://machine.name/tmp/vimtest2a and other text
|
|
|
|
second test for URL://machine.name/tmp/vimtest2b. And other text
|
|
|
|
third test for URL:\\machine.name\vimtest2c and other text
|
|
|
|
fourth test for URL:\\machine.name\tmp\vimtest2d, and other text]])
|
|
|
|
|
|
|
|
-- Go to the first URL and append it to the beginning
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('/^first', '/tmp', 'call append(0, expand("<cfile>"))')
|
2014-09-29 05:43:52 -07:00
|
|
|
|
|
|
|
-- Repeat for the second URL
|
|
|
|
-- this time, navigate to the word "URL" instead of "tmp"
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('/^second', '/URL', 'call append(1, expand("<cfile>"))')
|
2014-09-29 05:43:52 -07:00
|
|
|
|
|
|
|
-- Repeat for the remaining URLs. This time, the 'isfname' option must be
|
|
|
|
-- set to allow '\' in filenames
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('set isf=@,48-57,/,.,-,_,+,,,$,:,~,\\')
|
|
|
|
feed_command('/^third', '/name', 'call append(2, expand("<cfile>"))')
|
|
|
|
feed_command('/^fourth', '/URL', 'call append(3, expand("<cfile>"))')
|
2014-09-29 05:43:52 -07:00
|
|
|
|
|
|
|
-- Delete the initial text, which now starts at line 5
|
|
|
|
feed('5GdG')
|
|
|
|
|
|
|
|
-- The buffer should now contain:
|
|
|
|
expect([[
|
|
|
|
URL://machine.name/tmp/vimtest2a
|
|
|
|
URL://machine.name/tmp/vimtest2b
|
|
|
|
URL:\\machine.name\vimtest2c
|
|
|
|
URL:\\machine.name\tmp\vimtest2d]])
|
|
|
|
end)
|
|
|
|
end)
|