@@ -83,6 +83,10 @@ describe('formatter', () => {
83
83
;;
84
84
esac
85
85
86
+ echo one two three
87
+ echo four five six
88
+ echo seven eight nine
89
+
86
90
echo space redirects >/dev/null
87
91
88
92
function next() {
@@ -128,6 +132,10 @@ describe('formatter', () => {
128
132
;;
129
133
esac
130
134
135
+ echo one two three
136
+ echo four five six
137
+ echo seven eight nine
138
+
131
139
echo space redirects >/dev/null
132
140
133
141
function next() {
@@ -173,6 +181,10 @@ describe('formatter', () => {
173
181
;;
174
182
esac
175
183
184
+ echo one two three
185
+ echo four five six
186
+ echo seven eight nine
187
+
176
188
echo space redirects >/dev/null
177
189
178
190
function next() {
@@ -219,6 +231,10 @@ describe('formatter', () => {
219
231
;;
220
232
esac
221
233
234
+ echo one two three
235
+ echo four five six
236
+ echo seven eight nine
237
+
222
238
echo space redirects >/dev/null
223
239
224
240
function next() {
@@ -265,6 +281,10 @@ describe('formatter', () => {
265
281
;;
266
282
esac
267
283
284
+ echo one two three
285
+ echo four five six
286
+ echo seven eight nine
287
+
268
288
echo space redirects >/dev/null
269
289
270
290
function next() {
@@ -311,6 +331,10 @@ describe('formatter', () => {
311
331
;;
312
332
esac
313
333
334
+ echo one two three
335
+ echo four five six
336
+ echo seven eight nine
337
+
314
338
echo space redirects >/dev/null
315
339
316
340
function next()
@@ -333,6 +357,56 @@ describe('formatter', () => {
333
357
` )
334
358
} )
335
359
360
+ it ( 'should format with padding kept as-is when keepPadding is true' , async ( ) => {
361
+ const [ result ] = await getFormattingResult ( {
362
+ document : FIXTURE_DOCUMENT . SHFMT ,
363
+ formatOptions : { tabSize : 2 , insertSpaces : true } ,
364
+ shfmtConfig : { keepPadding : true } ,
365
+ } )
366
+ expect ( result ) . toMatchInlineSnapshot ( `
367
+ [
368
+ {
369
+ "newText": "#!/bin/bash
370
+ set -ueo pipefail
371
+
372
+ if [ -z "$arg" ]; then
373
+ echo indent
374
+ fi
375
+
376
+ echo binary &&
377
+ echo next line
378
+
379
+ case "$arg" in
380
+ a)
381
+ echo case indent
382
+ ;;
383
+ esac
384
+
385
+ echo one two three
386
+ echo four five six
387
+ echo seven eight nine
388
+
389
+ echo space redirects >/dev/null
390
+
391
+ function next() {
392
+ echo line
393
+ }
394
+ ",
395
+ "range": {
396
+ "end": {
397
+ "character": 2147483647,
398
+ "line": 2147483647,
399
+ },
400
+ "start": {
401
+ "character": 0,
402
+ "line": 0,
403
+ },
404
+ },
405
+ },
406
+ ]
407
+ ` )
408
+ } )
409
+
336
410
it ( 'should format with redirect operators followed by a space when spaceRedirects is true' , async ( ) => {
337
411
const [ result ] = await getFormattingResult ( {
338
412
document : FIXTURE_DOCUMENT . SHFMT ,
@@ -358,6 +432,10 @@ describe('formatter', () => {
358
432
;;
359
433
esac
360
434
435
+ echo one two three
436
+ echo four five six
437
+ echo seven eight nine
438
+
361
439
echo space redirects > /dev/null
362
440
363
441
function next() {
@@ -387,6 +465,7 @@ describe('formatter', () => {
387
465
binaryNextLine : true ,
388
466
caseIndent : true ,
389
467
funcNextLine : true ,
468
+ keepPadding : true ,
390
469
spaceRedirects : true ,
391
470
} ,
392
471
} )
@@ -401,18 +480,22 @@ describe('formatter', () => {
401
480
fi
402
481
403
482
echo binary \\
404
- && echo next line
483
+ && echo next line
405
484
406
485
case "$arg" in
407
486
a)
408
487
echo case indent
409
488
;;
410
489
esac
411
490
491
+ echo one two three
492
+ echo four five six
493
+ echo seven eight nine
494
+
412
495
echo space redirects > /dev/null
413
496
414
497
function next()
415
- {
498
+ {
416
499
echo line
417
500
}
418
501
",
0 commit comments