@@ -28,7 +28,8 @@ export class DocumentFormattingEditProvider implements vscode.DocumentFormatting
28
28
let jsScript = false ;
29
29
let sql = false ;
30
30
let sqlParens = 0 ;
31
- for ( let i = 0 ; i < document . lineCount ; i ++ ) {
31
+ const lineFrom = isClass ? 0 : 1 ; // just skip ROUTINE header
32
+ for ( let i = lineFrom ; i < document . lineCount ; i ++ ) {
32
33
const line = document . lineAt ( i ) ;
33
34
const text = this . stripLineComments ( line . text ) ;
34
35
@@ -40,7 +41,7 @@ export class DocumentFormattingEditProvider implements vscode.DocumentFormatting
40
41
jsScript = true ;
41
42
}
42
43
43
- if ( text . match ( "& sql" ) ) {
44
+ if ( text . match ( / ( & | # # ) s q l / i ) ) {
44
45
sql = true ;
45
46
sqlParens = 0 ;
46
47
}
@@ -184,8 +185,10 @@ export class DocumentFormattingEditProvider implements vscode.DocumentFormatting
184
185
const newText = line . text
185
186
. replace ( / " (?: " " | [ ^ " ] ) * " | \/ \* .* \* \/ | \/ \/ + .* | # # ; .* / g, toKeep )
186
187
. replace ( / (?< = ^ \s | { | } ) ( \s * ) ( \b ( [ a - z ] + ) \b ) / gi, formatCommand )
187
- . replace ( / ( [ { } ] ) (? ! \s | $ ) / g, "$1 " )
188
- . replace ( / (?< ! \s ) ( [ { } ] ) / g, " $1" )
188
+ . replace ( / { (? ! \s | } | $ ) / g, "{ " )
189
+ . replace ( / } (? ! \s | \. | $ ) / g, "} " )
190
+ . replace ( / (?< ! \s | { ) } / g, " }" )
191
+ . replace ( / (?< ! \s ) { / g, " {" )
189
192
. replace ( new RegExp ( restorePattern . join ( "|" ) , "g" ) , toRestore ) ;
190
193
191
194
if ( newText != line . text ) {
0 commit comments