@@ -345,7 +345,7 @@ class PSDocumentFormattingEditProvider implements
345345 // we do not return a valid array because our text edits
346346 // need to be executed in a particular order and it is
347347 // easier if we perform the edits ourselves
348- return this . applyEdit ( editor , uniqueEdits , range , 0 , index ) ;
348+ return this . applyEdit ( editor , uniqueEdits , 0 , index ) ;
349349 } )
350350 . then ( ( ) => {
351351 // execute the same rule again if we left out violations
@@ -365,7 +365,6 @@ class PSDocumentFormattingEditProvider implements
365365 private applyEdit (
366366 editor : TextEditor ,
367367 edits : ScriptRegion [ ] ,
368- range : Range ,
369368 markerIndex : number ,
370369 ruleIndex : number ) : Thenable < void > {
371370 if ( markerIndex >= edits . length ) {
@@ -377,27 +376,22 @@ class PSDocumentFormattingEditProvider implements
377376 let edit : ScriptRegion = edits [ markerIndex ] ;
378377 let editRange : Range = toRange ( edit ) ;
379378
380- if ( range === null || range . contains ( editRange . start ) ) {
381-
382- // accumulate the changes in number of lines
383- // get the difference between the number of lines in the replacement text and
384- // that of the original text
385- this . lineDiff += this . getNumLines ( edit . text ) - ( editRange . end . line - editRange . start . line + 1 ) ;
386- return editor . edit ( ( editBuilder ) => {
387- editBuilder . replace (
388- editRange ,
389- edit . text ) ;
390- } ,
391- {
392- undoStopAfter : undoStopAfter ,
393- undoStopBefore : undoStopBefore
394- } ) . then ( ( isEditApplied ) => {
395- return this . applyEdit ( editor , edits , range , markerIndex + 1 , ruleIndex ) ;
396- } ) ; // TODO handle rejection
397- }
398- else {
399- return this . applyEdit ( editor , edits , range , markerIndex + 1 , ruleIndex ) ;
400- }
379+
380+ // accumulate the changes in number of lines
381+ // get the difference between the number of lines in the replacement text and
382+ // that of the original text
383+ this . lineDiff += this . getNumLines ( edit . text ) - ( editRange . end . line - editRange . start . line + 1 ) ;
384+ return editor . edit ( ( editBuilder ) => {
385+ editBuilder . replace (
386+ editRange ,
387+ edit . text ) ;
388+ } ,
389+ {
390+ undoStopAfter : undoStopAfter ,
391+ undoStopBefore : undoStopBefore
392+ } ) . then ( ( isEditApplied ) => {
393+ return this . applyEdit ( editor , edits , markerIndex + 1 , ruleIndex ) ;
394+ } ) ; // TODO handle rejection
401395 }
402396
403397 private getNumLines ( text : string ) : number {
0 commit comments