aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/textobjects_spec.lua
blob: 96f655cc414f8840de4f2a830ababd720e32786c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
local helpers = require('test.functional.helpers')(after_each)
local call = helpers.call
local clear = helpers.clear
local command = helpers.command
local expect = helpers.expect
local source = helpers.source

describe('Text object', function()
  before_each(function()
    clear()
    command('set shada=')
    source([[
      function SelectionOut(data)
        new
        call setline(1, a:data)
        call setreg('"', '')
        normal! ggfrmavi)y
        $put =getreg('\"')
        call setreg('"', '')
        normal! `afbmavi)y
        $put =getreg('\"')
        call setreg('"', '')
        normal! `afgmavi)y
        $put =getreg('\"')
      endfunction
      ]])
  end)

  it('Test for vi) without cpo-M', function()
    command('set cpo-=M')
    call('SelectionOut', '(red \\(blue) green)')

    expect([[
      (red \(blue) green)
      red \(blue
      red \(blue
      ]])
  end)

  it('Test for vi) with cpo-M #1', function()
    command('set cpo+=M')
    call('SelectionOut', '(red \\(blue) green)')

    expect([[
      (red \(blue) green)
      red \(blue) green
      blue
      red \(blue) green]])
  end)

  it('Test for vi) with cpo-M #2', function()
    command('set cpo+=M')
    call('SelectionOut', '(red (blue\\) green)')

    expect([[
      (red (blue\) green)
      red (blue\) green
      blue\
      red (blue\) green]])
  end)
end)