File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ export default class Tokenizer {
3232 private buildRulesBeforeParams ( cfg : TokenizerOptions ) : TokenRule [ ] {
3333 return this . validRules ( [
3434 {
35- type : TokenType . BLOCK_COMMENT ,
35+ type : TokenType . DISABLE_COMMENT ,
3636 regex :
3737 / ( \/ \* * s q l - f o r m a t t e r - d i s a b l e * \* \/ [ \s \S ] * ?(?: \/ \* * s q l - f o r m a t t e r - e n a b l e * \* \/ | $ ) ) / uy,
3838 } ,
Original file line number Diff line number Diff line change @@ -28,6 +28,27 @@ export default function supportsDisableComment(format: FormatFn) {
2828 ` ) ;
2929 } ) ;
3030
31+ // Issue #906
32+ it ( 'preserves indentation between /* sql-formatter-disable */ and /* sql-formatter-enable */' , ( ) => {
33+ const result = format ( dedent `
34+ /* sql-formatter-disable */
35+ SELECT
36+ foo
37+ FROM
38+ bar;
39+ /* sql-formatter-enable */
40+ ` ) ;
41+
42+ expect ( result ) . toBe ( dedent `
43+ /* sql-formatter-disable */
44+ SELECT
45+ foo
46+ FROM
47+ bar;
48+ /* sql-formatter-enable */
49+ ` ) ;
50+ } ) ;
51+
3152 it ( 'does not format text after /* sql-formatter-disable */ until end of file' , ( ) => {
3253 const result = format ( dedent `
3354 SELECT foo FROM bar;
You can’t perform that action at this time.
0 commit comments