@@ -1233,11 +1233,6 @@ module FourSlash {
12331233 ts . forEach ( fileNames , Harness . IO . log ) ;
12341234 }
12351235
1236- private editCheckpoint ( filename : string ) {
1237- // TODO: What's this for? It is being called by deleteChar
1238- // this.languageService.getScriptLexicalStructure(filename);
1239- }
1240-
12411236 public deleteChar ( count = 1 ) {
12421237 this . scenarioActions . push ( '<DeleteCharNext Count="' + count + '" />' ) ;
12431238
@@ -1248,7 +1243,7 @@ module FourSlash {
12481243 // Make the edit
12491244 this . languageServiceShimHost . editScript ( this . activeFile . fileName , offset , offset + 1 , ch ) ;
12501245 this . updateMarkersForEdit ( this . activeFile . fileName , offset , offset + 1 , ch ) ;
1251- this . editCheckpoint ( this . activeFile . fileName ) ;
1246+ this . checkPostEditInvariants ( ) ;
12521247
12531248 // Handle post-keystroke formatting
12541249 if ( this . enableFormatting ) {
@@ -1269,7 +1264,7 @@ module FourSlash {
12691264
12701265 this . languageServiceShimHost . editScript ( this . activeFile . fileName , start , start + length , text ) ;
12711266 this . updateMarkersForEdit ( this . activeFile . fileName , start , start + length , text ) ;
1272- this . editCheckpoint ( this . activeFile . fileName ) ;
1267+ this . checkPostEditInvariants ( ) ;
12731268
12741269 this . checkPostEditInvariants ( ) ;
12751270 }
@@ -1285,21 +1280,20 @@ module FourSlash {
12851280 // Make the edit
12861281 this . languageServiceShimHost . editScript ( this . activeFile . fileName , offset , offset + 1 , ch ) ;
12871282 this . updateMarkersForEdit ( this . activeFile . fileName , offset , offset + 1 , ch ) ;
1288- this . editCheckpoint ( this . activeFile . fileName ) ;
1283+ this . checkPostEditInvariants ( ) ;
12891284
12901285 // Handle post-keystroke formatting
12911286 if ( this . enableFormatting ) {
12921287 var edits = this . languageService . getFormattingEditsAfterKeystroke ( this . activeFile . fileName , offset , ch , this . formatCodeOptions ) ;
12931288 offset += this . applyEdits ( this . activeFile . fileName , edits , true ) ;
1294- this . editCheckpoint ( this . activeFile . fileName ) ;
1289+ this . checkPostEditInvariants ( ) ;
12951290 }
12961291 }
12971292
12981293 // Move the caret to wherever we ended up
12991294 this . currentCaretPosition = offset ;
13001295
13011296 this . fixCaretPosition ( ) ;
1302-
13031297 this . checkPostEditInvariants ( ) ;
13041298 }
13051299
@@ -1325,22 +1319,23 @@ module FourSlash {
13251319 var ch = text . charAt ( i ) ;
13261320 this . languageServiceShimHost . editScript ( this . activeFile . fileName , offset , offset , ch ) ;
13271321 this . updateMarkersForEdit ( this . activeFile . fileName , offset , offset , ch ) ;
1328- this . editCheckpoint ( this . activeFile . fileName ) ;
1322+ this . checkPostEditInvariants ( ) ;
13291323 offset ++ ;
13301324
13311325 // Handle post-keystroke formatting
13321326 if ( this . enableFormatting ) {
13331327 var edits = this . languageService . getFormattingEditsAfterKeystroke ( this . activeFile . fileName , offset , ch , this . formatCodeOptions ) ;
1334- offset += this . applyEdits ( this . activeFile . fileName , edits , true ) ;
1335- this . editCheckpoint ( this . activeFile . fileName ) ;
1328+ if ( edits . length ) {
1329+ offset += this . applyEdits ( this . activeFile . fileName , edits , true ) ;
1330+ this . checkPostEditInvariants ( ) ;
1331+ }
13361332 }
13371333 }
13381334
13391335 // Move the caret to wherever we ended up
13401336 this . currentCaretPosition = offset ;
13411337
13421338 this . fixCaretPosition ( ) ;
1343-
13441339 this . checkPostEditInvariants ( ) ;
13451340 }
13461341
@@ -1357,7 +1352,7 @@ module FourSlash {
13571352 this . languageService . getBraceMatchingAtPosition ( this . activeFile . fileName , offset ) ;
13581353
13591354 this . updateMarkersForEdit ( this . activeFile . fileName , offset , offset , ch ) ;
1360- this . editCheckpoint ( this . activeFile . fileName ) ;
1355+ this . checkPostEditInvariants ( ) ;
13611356 offset ++ ;
13621357
13631358 if ( ch === '(' || ch === ',' ) {
@@ -1377,7 +1372,7 @@ module FourSlash {
13771372 if ( this . enableFormatting ) {
13781373 var edits = this . languageService . getFormattingEditsAfterKeystroke ( this . activeFile . fileName , offset , ch , this . formatCodeOptions ) ;
13791374 offset += this . applyEdits ( this . activeFile . fileName , edits , true ) ;
1380- this . editCheckpoint ( this . activeFile . fileName ) ;
1375+ this . checkPostEditInvariants ( ) ;
13811376 }
13821377 }
13831378
@@ -1397,14 +1392,14 @@ module FourSlash {
13971392 var offset = this . currentCaretPosition ;
13981393 this . languageServiceShimHost . editScript ( this . activeFile . fileName , offset , offset , text ) ;
13991394 this . updateMarkersForEdit ( this . activeFile . fileName , offset , offset , text ) ;
1400- this . editCheckpoint ( this . activeFile . fileName ) ;
1395+ this . checkPostEditInvariants ( ) ;
14011396 offset += text . length ;
14021397
14031398 // Handle formatting
14041399 if ( this . enableFormatting ) {
14051400 var edits = this . languageService . getFormattingEditsForRange ( this . activeFile . fileName , start , offset , this . formatCodeOptions ) ;
14061401 offset += this . applyEdits ( this . activeFile . fileName , edits , true ) ;
1407- this . editCheckpoint ( this . activeFile . fileName ) ;
1402+ this . checkPostEditInvariants ( ) ;
14081403 }
14091404
14101405 // Move the caret to wherever we ended up
0 commit comments