robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
1.7 KiB45 linesraw
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
4local n = require('test.functional.testnvim')()
5local t = require('test.testutil')
6
7local describe, it, setup = t.describe, t.it, t.setup
8local clear, feed, insert = n.clear, n.feed, n.insert
9local feed_command, expect = n.feed_command, n.expect
10
11describe('filename recognition', function()
12  setup(clear)
13
14  it('is working', function()
15    -- insert some lines containing URLs
16    insert([[
17      first test for URL://machine.name/tmp/vimtest2a and other text
18      second test for URL://machine.name/tmp/vimtest2b. And other text
19      third test for URL:\\machine.name\vimtest2c and other text
20      fourth test for URL:\\machine.name\tmp\vimtest2d, and other text]])
21
22    -- Go to the first URL and append it to the beginning
23    feed_command('/^first', '/tmp', 'call append(0, expand("<cfile>"))')
24
25    -- Repeat for the second URL
26    -- this time, navigate to the word "URL" instead of "tmp"
27    feed_command('/^second', '/URL', 'call append(1, expand("<cfile>"))')
28
29    -- Repeat for the remaining URLs. This time, the 'isfname' option must be
30    -- set to allow '\' in filenames
31    feed_command('set isf=@,48-57,/,.,-,_,+,,,$,:,~,\\')
32    feed_command('/^third', '/name', 'call append(2, expand("<cfile>"))')
33    feed_command('/^fourth', '/URL', 'call append(3, expand("<cfile>"))')
34
35    -- Delete the initial text, which now starts at line 5
36    feed('5GdG')
37
38    -- The buffer should now contain:
39    expect([[
40      URL://machine.name/tmp/vimtest2a
41      URL://machine.name/tmp/vimtest2b
42      URL:\\machine.name\vimtest2c
43      URL:\\machine.name\tmp\vimtest2d]])
44  end)
45end)