robin/laufey

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

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
1.3 KiB57 linesraw
1-- Tests for complicated + argument to :edit command
2
3local n = require('test.functional.testnvim')()
4local t = require('test.testutil')
5
6local describe, it, setup, teardown = t.describe, t.it, t.setup, t.teardown
7local clear, insert = n.clear, n.insert
8local command, expect = n.command, n.expect
9local poke_eventloop = n.poke_eventloop
10
11describe(':edit', function()
12  setup(clear)
13
14  it('is working', function()
15    insert([[
16      The result should be in Xfile1: "fooPIPEbar", in Xfile2: "fooSLASHbar"
17      foo|bar
18      foo/bar]])
19    poke_eventloop()
20
21    -- Prepare some test files
22    command('$-1w! Xfile1')
23    command('$w! Xfile2')
24    command('w! Xfile0')
25
26    -- Open Xfile using '+' range
27    command('edit +1 Xfile1')
28    command('s/|/PIPE/')
29    command('yank A')
30    command('w! Xfile1')
31
32    -- Open Xfile2 using '|' range
33    command('edit Xfile2|1')
34    command('s/\\//SLASH/')
35    command('yank A')
36    command('w! Xfile2')
37
38    -- Clean first buffer and put @a
39    command('bf')
40    command('%d')
41    command('0put a')
42
43    -- Remove empty line
44    command('$d')
45
46    -- The buffer should now contain
47    expect([[
48      fooPIPEbar
49      fooSLASHbar]])
50  end)
51
52  teardown(function()
53    os.remove('Xfile0')
54    os.remove('Xfile1')
55    os.remove('Xfile2')
56  end)
57end)