aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/listlbr_spec.lua
blob: 8b3f00aa62259703c62f038ef699a1f1a080f929 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
-- Test for linebreak and list option (non-utf8)

local helpers = require('test.functional.helpers')
local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect

describe('listlbr', function()
  setup(clear)

  it('is working', function()
    insert([=[
      dummy text]=])

    execute('set wildchar=^E')
    execute('10new')
    execute('vsp')
    execute('vert resize 20')
    execute([[put =\"\tabcdef hijklmn\tpqrstuvwxyz_1060ABCDEFGHIJKLMNOP \"]])
    execute('norm! zt')
    execute('set ts=4 sw=4 sts=4 linebreak sbr=+ wrap')
    execute('fu! ScreenChar(width)')
    execute([[	let c='']])
    execute('	for j in range(1,4)')
    execute('	    for i in range(1,a:width)')
    execute('	    	let c.=nr2char(screenchar(j, i))')
    execute('	    endfor')
    execute([[           let c.="\n"]])
    execute('	endfor')
    execute('	return c')
    execute('endfu')
    execute('fu! DoRecordScreen()')
    execute('	wincmd l')
    execute([[	$put =printf(\"\n%s\", g:test)]])
    execute('	$put =g:line')
    execute('	wincmd p')
    execute('endfu')
    execute('let g:test="Test 1: set linebreak"')
    execute('redraw!')
    execute('let line=ScreenChar(winwidth(0))')
    execute('call DoRecordScreen()')
    execute('let g:test="Test 2: set linebreak + set list"')
    execute('set linebreak list listchars=')
    execute('redraw!')
    execute('let line=ScreenChar(winwidth(0))')
    execute('call DoRecordScreen()')
    execute('let g:test ="Test 3: set linebreak nolist"')
    execute('set nolist linebreak')
    execute('redraw!')
    execute('let line=ScreenChar(winwidth(0))')
    execute('call DoRecordScreen()')
    execute('let g:test ="Test 4: set linebreak with tab and 1 line as long as screen: should break!"')
    execute('set nolist linebreak ts=8')
    execute([[let line="1\t".repeat('a', winwidth(0)-2)]])
    execute('$put =line')
    execute('$')
    execute('norm! zt')
    execute('redraw!')
    execute('let line=ScreenChar(winwidth(0))')
    execute('call DoRecordScreen()')
    execute([[let line="_S_\t bla"]])
    execute('$put =line')
    execute('$')
    execute('norm! zt')
    execute('let g:test ="Test 5: set linebreak with conceal and set list and tab displayed by different char (line may not be truncated)"')
    execute('set cpo&vim list linebreak conceallevel=2 concealcursor=nv listchars=tab:ab')
    execute('syn match ConcealVar contained /_/ conceal')
    execute('syn match All /.*/ contains=ConcealVar')
    execute('let line=ScreenChar(winwidth(0))')
    execute('call DoRecordScreen()')
    execute('set cpo&vim linebreak')
    execute('let g:test ="Test 6: set linebreak with visual block mode"')
    execute('let line="REMOVE: this not"')
    execute('$put =g:test')
    execute('$put =line')
    execute('let line="REMOVE: aaaaaaaaaaaaa"')
    execute('$put =line')
    execute('1/^REMOVE:')
    feed('0<C-V>jf x')
    execute('$put')
    execute('set cpo&vim linebreak')
    execute('let g:test ="Test 7: set linebreak with visual block mode and v_b_A"')
    execute('$put =g:test')
    feed('Golong line: <esc>40afoobar <esc>aTARGET at end<esc>')
    execute([[exe "norm! $3B\<C-v>eAx\<Esc>"]])
    execute('set cpo&vim linebreak sbr=')
    execute('let g:test ="Test 8: set linebreak with visual char mode and changing block"')
    execute('$put =g:test')
    feed('Go1111-1111-1111-11-1111-1111-1111<esc>0f-lv3lc2222<esc>bgj.')

    -- Assert buffer contents.
    expect([=[
      
      	abcdef hijklmn	pqrstuvwxyz_1060ABCDEFGHIJKLMNOP 
      
      Test 1: set linebreak
          abcdef          
      +hijklmn            
      +pqrstuvwxyz_1060ABC
      +DEFGHIJKLMNOP      
      
      Test 2: set linebreak + set list
      ^Iabcdef hijklmn^I  
      +pqrstuvwxyz_1060ABC
      +DEFGHIJKLMNOP      
                          
      
      Test 3: set linebreak nolist
          abcdef          
      +hijklmn            
      +pqrstuvwxyz_1060ABC
      +DEFGHIJKLMNOP      
      1	aaaaaaaaaaaaaaaaaa
      
      Test 4: set linebreak with tab and 1 line as long as screen: should break!
      1                   
      +aaaaaaaaaaaaaaaaaa 
      ~                   
      ~                   
      _S_	 bla
      
      Test 5: set linebreak with conceal and set list and tab displayed by different char (line may not be truncated)
      Sabbbbbb bla        
      ~                   
      ~                   
      ~                   
      Test 6: set linebreak with visual block mode
      this not
      aaaaaaaaaaaaa
      REMOVE: 
      REMOVE: 
      Test 7: set linebreak with visual block mode and v_b_A
      long line: foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar TARGETx at end
      Test 8: set linebreak with visual char mode and changing block
      1111-2222-1111-11-1111-2222-1111]=])
  end)
end)