@@ -23,7 +23,7 @@ namespace ts.OrganizeImports {
2323
2424 // All of the old ImportDeclarations in the file, in syntactic order.
2525 const topLevelImportGroupDecls = groupImportsByNewlineContiguous ( sourceFile . statements . filter ( isImportDeclaration ) , host , formatContext ) ;
26- topLevelImportGroupDecls . forEach ( topLevelImportGroupDecl => organizeImportsWorker ( topLevelImportGroupDecl , coalesceAndOrganizeImports ) ) ;
26+ topLevelImportGroupDecls . forEach ( importGroupDecl => organizeImportsWorker ( importGroupDecl , coalesceAndOrganizeImports ) ) ;
2727
2828 // All of the old ExportDeclarations in the file, in syntactic order.
2929 const topLevelExportDecls = sourceFile . statements . filter ( isExportDeclaration ) ;
@@ -33,7 +33,7 @@ namespace ts.OrganizeImports {
3333 if ( ! ambientModule . body ) continue ;
3434
3535 const ambientModuleImportGroupDecls = groupImportsByNewlineContiguous ( ambientModule . body . statements . filter ( isImportDeclaration ) , host , formatContext ) ;
36- ambientModuleImportGroupDecls . forEach ( ambientModuleImportGroupDecl => organizeImportsWorker ( ambientModuleImportGroupDecl , coalesceAndOrganizeImports ) ) ;
36+ ambientModuleImportGroupDecls . forEach ( importGroupDecl => organizeImportsWorker ( importGroupDecl , coalesceAndOrganizeImports ) ) ;
3737
3838 const ambientModuleExportDecls = ambientModule . body . statements . filter ( isExportDeclaration ) ;
3939 organizeImportsWorker ( ambientModuleExportDecls , coalesceExports ) ;
@@ -92,11 +92,9 @@ namespace ts.OrganizeImports {
9292 const newLine = getNewLineOrDefaultFromHost ( host , formatContext . options ) ;
9393 const prefixCond = `${ newLine } ${ newLine } ` ;
9494
95- for ( let importIndex = 0 , groupIndex = 0 , length = importDecls . length ; importIndex < length ; ++ importIndex ) {
96- const topLevelImportDecl = importDecls [ importIndex ] ;
97- const leadingText = topLevelImportDecl . getFullText ( ) . substring (
98- 0 ,
99- topLevelImportDecl . getStart ( ) - topLevelImportDecl . getFullStart ( ) ) ;
95+ let groupIndex = 0 ;
96+ for ( const topLevelImportDecl of importDecls ) {
97+ const leadingText = topLevelImportDecl . getFullText ( ) . substring ( 0 , topLevelImportDecl . getStart ( ) - topLevelImportDecl . getFullStart ( ) ) ;
10098
10199 if ( startsWith ( leadingText , prefixCond ) ) {
102100 groupIndex ++ ;
0 commit comments