@@ -339,17 +339,17 @@ namespace ts.formatting {
339339 /* @internal */
340340 export function formatNodeGivenIndentation ( node : Node , sourceFileLike : SourceFileLike , languageVariant : LanguageVariant , initialIndentation : number , delta : number , rulesProvider : RulesProvider ) : TextChange [ ] {
341341 const range = { pos : 0 , end : sourceFileLike . text . length } ;
342- return formatSpanWorker (
342+ return getFormattingScanner ( sourceFileLike . text , languageVariant , range . pos , range . end , scanner => formatSpanWorker (
343343 range ,
344344 node ,
345345 initialIndentation ,
346346 delta ,
347- getFormattingScanner ( sourceFileLike . text , languageVariant , range . pos , range . end ) ,
347+ scanner ,
348348 rulesProvider . getFormatOptions ( ) ,
349349 rulesProvider ,
350350 FormattingRequestKind . FormatSelection ,
351351 _ => false , // assume that node does not have any errors
352- sourceFileLike ) ;
352+ sourceFileLike ) ) ;
353353 }
354354
355355 function formatNodeLines ( node : Node , sourceFile : SourceFile , options : FormatCodeSettings , rulesProvider : RulesProvider , requestKind : FormattingRequestKind ) : TextChange [ ] {
@@ -372,17 +372,17 @@ namespace ts.formatting {
372372 requestKind : FormattingRequestKind ) : TextChange [ ] {
373373 // find the smallest node that fully wraps the range and compute the initial indentation for the node
374374 const enclosingNode = findEnclosingNode ( originalRange , sourceFile ) ;
375- return formatSpanWorker (
375+ return getFormattingScanner ( sourceFile . text , sourceFile . languageVariant , getScanStartPosition ( enclosingNode , originalRange , sourceFile ) , originalRange . end , scanner => formatSpanWorker (
376376 originalRange ,
377377 enclosingNode ,
378378 SmartIndenter . getIndentationForNode ( enclosingNode , originalRange , sourceFile , options ) ,
379379 getOwnOrInheritedDelta ( enclosingNode , options , sourceFile ) ,
380- getFormattingScanner ( sourceFile . text , sourceFile . languageVariant , getScanStartPosition ( enclosingNode , originalRange , sourceFile ) , originalRange . end ) ,
380+ scanner ,
381381 options ,
382382 rulesProvider ,
383383 requestKind ,
384384 prepareRangeContainsErrorFunction ( sourceFile . parseDiagnostics , originalRange ) ,
385- sourceFile ) ;
385+ sourceFile ) ) ;
386386 }
387387
388388 function formatSpanWorker ( originalRange : TextRange ,
@@ -427,8 +427,6 @@ namespace ts.formatting {
427427 }
428428 }
429429
430- formattingScanner . close ( ) ;
431-
432430 return edits ;
433431
434432 // local functions
0 commit comments