File: failed-selection.vim

package info (click to toggle)
vim-textobj-user 0.7.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 208 kB
  • sloc: makefile: 2
file content (63 lines) | stat: -rw-r--r-- 1,529 bytes parent folder | download | duplicates (2)
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
62
63
call textobj#user#plugin('alwaysfail', {
\   'pattern1': {
\     'pattern': 'no such pattern',
\     'select': '[p]',
\   },
\   'pattern2': {
\     'pattern': ['no such', 'pattern'],
\     'select-a': '[pa]',
\     'select-i': '[pi]',
\   },
\   'function': {
\     'select': '[sf]',
\     'select-function': 'CannotSelect',
\     'select-a': '[saf]',
\     'select-a-function': 'CannotSelect',
\     'select-i': '[sif]',
\     'select-i-function': 'CannotSelect',
\   },
\ })

function! CannotSelect()
  return 0
endfunction

describe 'textobj-user'
  before
    new
    put ='1'
    put ='22'
    put ='333'
    put ='4444'
    put ='55555'
    put ='666666'
    1 delete _
  end

  after
    close!
  end

  it 'operates on nothing if a proper text object is not found'
    for obj in ['p', 'pa', 'pi', 'sf', 'saf', 'sif']
      call cursor(3, 2)
      execute 'normal' printf('y[%s]', obj)
      Expect @0 == ''
      Expect [obj, line("'["), col("'["), line("']"), col("']")]
      \ == [obj, 3, 2, 3, 2]
      Expect [obj, line("'<"), col("'<"), line("'>"), col("'>")]
      \ == [obj, 0, 0, 0, 0]
    endfor
  end

  it 'keeps the current selection if a proper text object is not found'
    for obj in ['p', 'pa', 'pi', 'sf', 'saf', 'sif']
      call cursor(3, 2)
      execute 'normal' printf('vjjl[%s]y', obj)
      Expect [obj, line("'["), col("'["), line("']"), col("']")]
      \ == [obj, 3, 2, 5, 3]
      Expect [obj, line("'<"), col("'<"), line("'>"), col("'>")]
      \ == [obj, 3, 2, 5, 3]
    endfor
  end
end