@@ -348,16 +348,31 @@ export class TimeTravelActions extends CodeEditorActions<TimeTravelState> {
348
348
}
349
349
} ;
350
350
351
- setGitMode = ( id : string , git_mode : boolean ) : void => {
351
+ setGitMode = async ( id : string , git_mode : boolean ) => {
352
352
for ( const actions of [ this , this . ambient_actions ] ) {
353
353
if ( actions == null ) continue ;
354
354
const node = actions . _get_frame_node ( id ) ;
355
355
if ( node == null ) continue ;
356
+ const cur = ! ! node . get ( "git_mode" ) ;
356
357
git_mode = ! ! git_mode ;
357
- actions . set_frame_tree ( { id, git_mode } ) ;
358
+ if ( cur != git_mode ) {
359
+ // actually changing it
360
+ actions . set_frame_tree ( { id, git_mode } ) ;
361
+ let versions ;
362
+ if ( git_mode ) {
363
+ // also set version to newest on change to git mode
364
+ versions =
365
+ this . store . get ( "git_versions" ) ?? ( await this . updateGitVersions ( ) ) ;
366
+ } else {
367
+ // set version to newest on change from git mode to time travel
368
+ versions = this . store . get ( "versions" ) ;
369
+ }
370
+ if ( versions != null ) {
371
+ actions . set_frame_tree ( { id, version : versions . size - 1 } ) ;
372
+ }
373
+ }
358
374
break ;
359
375
}
360
- this . updateGitVersions ( ) ;
361
376
} ;
362
377
363
378
setVersions = ( id : string , version0 : number , version1 : number ) : void => {
@@ -482,6 +497,7 @@ export class TimeTravelActions extends CodeEditorActions<TimeTravelState> {
482
497
git_versions,
483
498
} ) ;
484
499
this . ensureSelectedVersionsAreConsistent ( { git_versions } ) ;
500
+ return git_versions ;
485
501
} catch ( err ) {
486
502
this . set_error ( `${ err } ` ) ;
487
503
this . setState ( { git : false } ) ;
0 commit comments