@@ -83,6 +83,10 @@ describe('formatter', () => {
8383 ;;
8484 esac
8585
86+ echo one two three
87+ echo four five six
88+ echo seven eight nine
89+
8690 echo space redirects >/dev/null
8791
8892 function next() {
@@ -128,6 +132,10 @@ describe('formatter', () => {
128132 ;;
129133 esac
130134
135+ echo one two three
136+ echo four five six
137+ echo seven eight nine
138+
131139 echo space redirects >/dev/null
132140
133141 function next() {
@@ -173,6 +181,10 @@ describe('formatter', () => {
173181 ;;
174182 esac
175183
184+ echo one two three
185+ echo four five six
186+ echo seven eight nine
187+
176188 echo space redirects >/dev/null
177189
178190 function next() {
@@ -219,6 +231,10 @@ describe('formatter', () => {
219231 ;;
220232 esac
221233
234+ echo one two three
235+ echo four five six
236+ echo seven eight nine
237+
222238 echo space redirects >/dev/null
223239
224240 function next() {
@@ -265,6 +281,10 @@ describe('formatter', () => {
265281 ;;
266282 esac
267283
284+ echo one two three
285+ echo four five six
286+ echo seven eight nine
287+
268288 echo space redirects >/dev/null
269289
270290 function next() {
@@ -311,6 +331,10 @@ describe('formatter', () => {
311331 ;;
312332 esac
313333
334+ echo one two three
335+ echo four five six
336+ echo seven eight nine
337+
314338 echo space redirects >/dev/null
315339
316340 function next()
@@ -333,6 +357,56 @@ describe('formatter', () => {
333357 ` )
334358 } )
335359
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+
336410 it ( 'should format with redirect operators followed by a space when spaceRedirects is true' , async ( ) => {
337411 const [ result ] = await getFormattingResult ( {
338412 document : FIXTURE_DOCUMENT . SHFMT ,
@@ -358,6 +432,10 @@ describe('formatter', () => {
358432 ;;
359433 esac
360434
435+ echo one two three
436+ echo four five six
437+ echo seven eight nine
438+
361439 echo space redirects > /dev/null
362440
363441 function next() {
@@ -387,6 +465,7 @@ describe('formatter', () => {
387465 binaryNextLine : true ,
388466 caseIndent : true ,
389467 funcNextLine : true ,
468+ keepPadding : true ,
390469 spaceRedirects : true ,
391470 } ,
392471 } )
@@ -401,18 +480,22 @@ describe('formatter', () => {
401480 fi
402481
403482 echo binary \\
404- && echo next line
483+ && echo next line
405484
406485 case "$arg" in
407486 a)
408487 echo case indent
409488 ;;
410489 esac
411490
491+ echo one two three
492+ echo four five six
493+ echo seven eight nine
494+
412495 echo space redirects > /dev/null
413496
414497 function next()
415- {
498+ {
416499 echo line
417500 }
418501 ",
0 commit comments