002_filename_recognition_spec.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. -- Test if URLs are recognized as filenames by commands such as "gf". Here
  2. -- we'll use `expand("<cfile>")` since "gf" would need to open the file.
  3. local helpers = require('test.functional.helpers')(after_each)
  4. local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
  5. local feed_command, expect = helpers.feed_command, helpers.expect
  6. describe('filename recognition', function()
  7. setup(clear)
  8. it('is working', function()
  9. -- insert some lines containing URLs
  10. insert([[
  11. first test for URL://machine.name/tmp/vimtest2a and other text
  12. second test for URL://machine.name/tmp/vimtest2b. And other text
  13. third test for URL:\\machine.name\vimtest2c and other text
  14. fourth test for URL:\\machine.name\tmp\vimtest2d, and other text]])
  15. -- Go to the first URL and append it to the beginning
  16. feed_command('/^first', '/tmp', 'call append(0, expand("<cfile>"))')
  17. -- Repeat for the second URL
  18. -- this time, navigate to the word "URL" instead of "tmp"
  19. feed_command('/^second', '/URL', 'call append(1, expand("<cfile>"))')
  20. -- Repeat for the remaining URLs. This time, the 'isfname' option must be
  21. -- set to allow '\' in filenames
  22. feed_command('set isf=@,48-57,/,.,-,_,+,,,$,:,~,\\')
  23. feed_command('/^third', '/name', 'call append(2, expand("<cfile>"))')
  24. feed_command('/^fourth', '/URL', 'call append(3, expand("<cfile>"))')
  25. -- Delete the initial text, which now starts at line 5
  26. feed('5GdG')
  27. -- The buffer should now contain:
  28. expect([[
  29. URL://machine.name/tmp/vimtest2a
  30. URL://machine.name/tmp/vimtest2b
  31. URL:\\machine.name\vimtest2c
  32. URL:\\machine.name\tmp\vimtest2d]])
  33. end)
  34. end)