File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
src/packages/frontend/frame-editors/code-editor Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -1281,11 +1281,29 @@ export class Actions<
12811281 }
12821282
12831283 time_travel ( opts : { path ?: string ; frame ?: boolean } ) : void {
1284+ const path = opts ?. path ?? this . path ;
1285+ if ( path . startsWith ( ".snapshots/" ) ) {
1286+ // see https://github.com/sagemathinc/cocalc/issues/2588
1287+ let file = path . slice ( ".snapshots/" . length ) ;
1288+ // if file's first path segment starts with an iso timestamp like, '2023-06-03-153543', remove that:
1289+ const parts = file . split ( "/" ) ;
1290+ if ( parts . length > 0 && / ^ \d { 4 } - \d { 2 } - \d { 2 } - \d { 6 } $ / . test ( parts [ 0 ] ) ) {
1291+ parts . shift ( ) ;
1292+ file = parts . join ( "/" ) ;
1293+ }
1294+ const hist = history_path ( file ) ;
1295+ this . _get_project_actions ( ) . open_file ( {
1296+ path : hist ,
1297+ foreground : true ,
1298+ } ) ;
1299+ return ;
1300+ }
1301+
12841302 if ( opts . frame ) {
12851303 this . show_focused_frame_of_type ( "time_travel" ) ;
12861304 } else {
12871305 this . _get_project_actions ( ) . open_file ( {
1288- path : history_path ( opts . path || this . path ) ,
1306+ path : history_path ( path ) ,
12891307 foreground : true ,
12901308 } ) ;
12911309 }
You can’t perform that action at this time.
0 commit comments