@@ -33,6 +33,7 @@ const workspaceResource = URI.file(platform.isWindows ? 'c:\\workspace' : '/work
3333const workspaceBackupPath = path . join ( backupHome , hashPath ( workspaceResource ) ) ;
3434const fooFile = URI . file ( platform . isWindows ? 'c:\\Foo' : '/Foo' ) ;
3535const customFile = URI . parse ( 'customScheme://some/path' ) ;
36+ const customFileWithFragment = URI . parse ( 'customScheme2://some/path#fragment' ) ;
3637const barFile = URI . file ( platform . isWindows ? 'c:\\Bar' : '/Bar' ) ;
3738const fooBarFile = URI . file ( platform . isWindows ? 'c:\\Foo Bar' : '/Foo Bar' ) ;
3839const untitledFile = URI . from ( { scheme : Schemas . untitled , path : 'Untitled-1' } ) ;
@@ -162,7 +163,7 @@ suite('BackupFileService', () => {
162163 await service . backupResource ( fooFile , createTextBufferFactory ( 'test' ) . create ( DefaultEndOfLine . LF ) . createSnapshot ( false ) , undefined , { etag : '678' , orphaned : true } ) ;
163164 assert . equal ( fs . readdirSync ( path . join ( workspaceBackupPath , 'file' ) ) . length , 1 ) ;
164165 assert . equal ( fs . existsSync ( fooBackupPath ) , true ) ;
165- assert . equal ( fs . readFileSync ( fooBackupPath ) . toString ( ) , `${ fooFile . toString ( ) } # {"etag":"678","orphaned":true}\ntest` ) ;
166+ assert . equal ( fs . readFileSync ( fooBackupPath ) . toString ( ) , `${ fooFile . toString ( ) } {"etag":"678","orphaned":true}\ntest` ) ;
166167 } ) ;
167168
168169 test ( 'untitled file' , async ( ) => {
@@ -390,6 +391,8 @@ suite('BackupFileService', () => {
390391
391392 await service . backupResource ( fooFile , createTextBufferFactory ( contents ) . create ( DefaultEndOfLine . LF ) . createSnapshot ( false ) , 1 , meta ) ;
392393
394+ assert . ok ( await service . loadBackupResource ( fooFile ) ) ;
395+
393396 const fileContents = fs . readFileSync ( fooBackupPath ) . toString ( ) ;
394397 assert . equal ( fileContents . indexOf ( fooFile . toString ( ) ) , 0 ) ;
395398
@@ -402,6 +405,24 @@ suite('BackupFileService', () => {
402405 assert . ok ( ! backup . meta ) ;
403406 } ) ;
404407
408+ test ( 'should restore the original contents (text file with metadata and fragment URI)' , async ( ) => {
409+ const contents = [
410+ 'Lorem ipsum ' ,
411+ 'dolor öäü sit amet ' ,
412+ 'adipiscing ßß elit' ,
413+ 'consectetur '
414+ ] . join ( '' ) ;
415+
416+ const meta = {
417+ etag : 'theEtag' ,
418+ size : 888 ,
419+ mtime : Date . now ( ) ,
420+ orphaned : false
421+ } ;
422+
423+ await testResolveBackup ( customFileWithFragment , contents , meta ) ;
424+ } ) ;
425+
405426 test ( 'should restore the original contents (text file with space in name with metadata)' , async ( ) => {
406427 const contents = [
407428 'Lorem ipsum ' ,
@@ -445,7 +466,7 @@ suite('BackupFileService', () => {
445466
446467 await service . backupResource ( resource , createTextBufferFactory ( contents ) . create ( DefaultEndOfLine . LF ) . createSnapshot ( false ) , 1 , meta ) ;
447468
448- assert . ok ( service . loadBackupResource ( resource ) ) ;
469+ assert . ok ( await service . loadBackupResource ( resource ) ) ;
449470
450471 const backup = await service . resolveBackupContent < IBackupTestMetaData > ( service . toBackupResource ( resource ) ) ;
451472 assert . equal ( contents , snapshotToString ( backup . value . create ( platform . isWindows ? DefaultEndOfLine . CRLF : DefaultEndOfLine . LF ) . createSnapshot ( true ) ) ) ;
0 commit comments