@@ -339,17 +339,17 @@ namespace ts.formatting {
339
339
/* @internal */
340
340
export function formatNodeGivenIndentation ( node : Node , sourceFileLike : SourceFileLike , languageVariant : LanguageVariant , initialIndentation : number , delta : number , rulesProvider : RulesProvider ) : TextChange [ ] {
341
341
const range = { pos : 0 , end : sourceFileLike . text . length } ;
342
- return formatSpanWorker (
342
+ return getFormattingScanner ( sourceFileLike . text , languageVariant , range . pos , range . end , scanner => formatSpanWorker (
343
343
range ,
344
344
node ,
345
345
initialIndentation ,
346
346
delta ,
347
- getFormattingScanner ( sourceFileLike . text , languageVariant , range . pos , range . end ) ,
347
+ scanner ,
348
348
rulesProvider . getFormatOptions ( ) ,
349
349
rulesProvider ,
350
350
FormattingRequestKind . FormatSelection ,
351
351
_ => false , // assume that node does not have any errors
352
- sourceFileLike ) ;
352
+ sourceFileLike ) ) ;
353
353
}
354
354
355
355
function formatNodeLines ( node : Node , sourceFile : SourceFile , options : FormatCodeSettings , rulesProvider : RulesProvider , requestKind : FormattingRequestKind ) : TextChange [ ] {
@@ -372,17 +372,17 @@ namespace ts.formatting {
372
372
requestKind : FormattingRequestKind ) : TextChange [ ] {
373
373
// find the smallest node that fully wraps the range and compute the initial indentation for the node
374
374
const enclosingNode = findEnclosingNode ( originalRange , sourceFile ) ;
375
- return formatSpanWorker (
375
+ return getFormattingScanner ( sourceFile . text , sourceFile . languageVariant , getScanStartPosition ( enclosingNode , originalRange , sourceFile ) , originalRange . end , scanner => formatSpanWorker (
376
376
originalRange ,
377
377
enclosingNode ,
378
378
SmartIndenter . getIndentationForNode ( enclosingNode , originalRange , sourceFile , options ) ,
379
379
getOwnOrInheritedDelta ( enclosingNode , options , sourceFile ) ,
380
- getFormattingScanner ( sourceFile . text , sourceFile . languageVariant , getScanStartPosition ( enclosingNode , originalRange , sourceFile ) , originalRange . end ) ,
380
+ scanner ,
381
381
options ,
382
382
rulesProvider ,
383
383
requestKind ,
384
384
prepareRangeContainsErrorFunction ( sourceFile . parseDiagnostics , originalRange ) ,
385
- sourceFile ) ;
385
+ sourceFile ) ) ;
386
386
}
387
387
388
388
function formatSpanWorker ( originalRange : TextRange ,
@@ -427,8 +427,6 @@ namespace ts.formatting {
427
427
}
428
428
}
429
429
430
- formattingScanner . close ( ) ;
431
-
432
430
return edits ;
433
431
434
432
// local functions
0 commit comments