robin/laufey

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

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
2.8 KiB214 linesraw
1local n = require('test.functional.testnvim')()
2local t = require('test.testutil')
3
4local describe, it, setup = t.describe, t.it, t.setup
5local feed = n.feed
6local clear = n.clear
7local insert = n.insert
8local feed_command = n.feed_command
9local expect = n.expect
10
11describe('text formatting', function()
12  setup(clear)
13
14  -- luacheck: ignore 613 (Trailing whitespace in a string)
15  it('is working', function()
16    -- The control character <C-A> (byte \x01) needs to be put in the buffer
17    -- directly.  But the insert function sends the text to nvim in insert
18    -- mode so it has to be escaped with <C-V>.
19    insert([[
20      Results of test68:
21
22
23      {
24
25
26      }
27
28
29      {
30      a  b  
31
32      a    
33      }
34
35
36      {
37      a 
38      }
39
40
41      {
42      a b
43      #a b
44      }
45
46
47      {
48        1 a
49      # 1 a
50      }
51
52
53      {
54
55        x a
56        b
57       c
58
59      }
60
61
62      {
63      # 1 a b
64      }
65
66
67      {
68      # x
69      #   a b
70      }
71
72
73      {
74         1aa
75         2bb
76      }
77
78
79      /* abc def ghi jkl 
80       *    mno pqr stu
81       */
82
83
84      # 1 xxxxx
85      ]])
86
87    feed_command('/^{/+1')
88    feed_command('set noai tw=2 fo=t')
89    feed('gRa b<esc>')
90
91    feed_command('/^{/+1')
92    feed_command('set ai tw=2 fo=tw')
93    feed('gqgqjjllab<esc>')
94
95    feed_command('/^{/+1')
96    feed_command('set tw=3 fo=t')
97    feed('gqgqo<cr>')
98    feed('a <C-V><C-A><esc><esc>')
99
100    feed_command('/^{/+1')
101    feed_command('set tw=2 fo=tcq1 comments=:#')
102    feed('gqgqjgqgqo<cr>')
103    feed('a b<cr>')
104    feed('#a b<esc>')
105
106    feed_command('/^{/+1')
107    feed_command('set tw=5 fo=tcn comments=:#')
108    feed('A b<esc>jA b<esc>')
109
110    feed_command('/^{/+3')
111    feed_command('set tw=5 fo=t2a si')
112    feed('i  <esc>A_<esc>')
113
114    feed_command('/^{/+1')
115    feed_command('set tw=5 fo=qn comments=:#')
116    feed('gwap<cr>')
117
118    feed_command('/^{/+1')
119    feed_command('set tw=5 fo=q2 comments=:#')
120    feed('gwap<cr>')
121
122    feed_command('/^{/+2')
123    feed_command('set tw& fo=a')
124    feed('I^^<esc><esc>')
125
126    feed_command('/mno pqr/')
127    feed_command('setl tw=20 fo=an12wcq comments=s1:/*,mb:*,ex:*/')
128    feed('A vwx yz<esc>')
129
130    feed_command('/^#/')
131    feed_command('setl tw=12 fo=tqnc comments=:#')
132    feed('A foobar<esc>')
133
134    -- Assert buffer contents.
135    expect([[
136      Results of test68:
137
138
139      {
140      a
141      b
142      }
143
144
145      {
146      a  
147      b  
148
149      a  
150      b
151      }
152
153
154      {
155      a
156      
157
158      a
159      
160      }
161
162
163      {
164      a b
165      #a b
166
167      a b
168      #a b
169      }
170
171
172      {
173        1 a
174          b
175      # 1 a
176      #   b
177      }
178
179
180      {
181
182        x a
183          b_
184          c
185
186      }
187
188
189      {
190      # 1 a
191      #   b
192      }
193
194
195      {
196      # x a
197      #   b
198      }
199
200
201      { 1aa ^^2bb }
202
203
204      /* abc def ghi jkl 
205       *    mno pqr stu 
206       *    vwx yz
207       */
208
209
210      # 1 xxxxx
211      #   foobar
212      ]])
213  end)
214end)