robin/laufey

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

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
1.0 KiB55 linesraw
1-- vim: set foldmethod=marker foldmarker=[[,]] :
2-- Tests for multi-line regexps with ":s"
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 expect = n.expect
10
11describe('multi-line regexp', function()
12  setup(clear)
13
14  it('is working', function()
15    insert([[
16      1 aa
17      bb
18      cc
19      2 dd
20      ee
21      3 ef
22      gh
23      4 ij
24      5 a8
25      8b c9
26      9d
27      6 e7
28      77f
29      xxxxx]])
30
31    -- Test if replacing a line break works with a back reference
32    feed([[:/^1/,/^2/s/\n\(.\)/ \1/<cr>]])
33
34    -- Test if inserting a line break works with a back reference
35    feed([[:/^3/,/^4/s/\(.\)$/\r\1/<cr>]])
36
37    -- Test if replacing a line break with another line break works
38    feed([[:/^5/,/^6/s/\(\_d\{3}\)/x\1x/<cr>]])
39
40    expect([[
41      1 aa bb cc 2 dd ee
42      3 e
43      f
44      g
45      h
46      4 i
47      j
48      5 ax8
49      8xb cx9
50      9xd
51      6 ex7
52      7x7f
53      xxxxx]])
54  end)
55end)