@@ -16,29 +16,29 @@ export class TemporaryState extends vscode.Disposable {
1616
1717 constructor ( private readonly _storageUri : vscode . Uri ) {
1818 super ( ( ) => disposeAll ( this . _disposables ) ) ;
19- }
20-
19+ }
20+
2121 private get _path ( ) : vscode . Uri {
2222 return vscode . Uri . joinPath ( this . _storageUri , this . _SUBPATH ) ;
23- }
24-
23+ }
24+
2525 override dispose ( ) {
2626 disposeAll ( this . _disposables ) ;
2727 disposeAll ( this . _persistInSessionDisposables ) ;
28- }
29-
28+ }
29+
3030 private _addDisposable ( disposable : vscode . Disposable , persistInSession : boolean ) {
3131 if ( persistInSession ) {
3232 this . _persistInSessionDisposables . push ( disposable ) ;
3333 } else {
3434 if ( this . _disposables . length > 30 ) {
35- const oldDisposable = this . _disposables . shift ( ) ;
36- oldDisposable ?. dispose ( ) ;
37- }
35+ const oldDisposable = this . _disposables . shift ( ) ;
36+ oldDisposable ?. dispose ( ) ;
37+ }
3838 this . _disposables . push ( disposable ) ;
3939 }
40- }
41-
40+ }
41+
4242 private async _writeState ( subpath : string , filename : string , contents : Uint8Array , persistInSession : boolean ) : Promise < vscode . Uri > {
4343 let filePath : vscode . Uri = this . _path ;
4444 const workspace = ( vscode . workspace . workspaceFolders && vscode . workspace . workspaceFolders . length > 0 )
@@ -64,10 +64,10 @@ export class TemporaryState extends vscode.Disposable {
6464 }
6565 }
6666 } ;
67- this . _addDisposable ( dispose , persistInSession ) ;
68- return file ;
69- }
70-
67+ this . _addDisposable ( dispose , persistInSession ) ;
68+ return file ;
69+ }
70+
7171 private async _readState ( subpath : string , filename : string ) : Promise < Uint8Array > {
7272 let filePath : vscode . Uri = this . _path ;
7373 const workspace = ( vscode . workspace . workspaceFolders && vscode . workspace . workspaceFolders . length > 0 )
@@ -82,36 +82,36 @@ export class TemporaryState extends vscode.Disposable {
8282 }
8383
8484 static async init ( context : vscode . ExtensionContext ) : Promise < vscode . Disposable | undefined > {
85- if ( context . globalStorageUri && ! tempState ) {
86- tempState = new TemporaryState ( context . globalStorageUri ) ;
85+ if ( context . globalStorageUri && ! tempState ) {
86+ tempState = new TemporaryState ( context . globalStorageUri ) ;
8787 try {
8888 await vscode . workspace . fs . delete ( tempState . _path , { recursive : true } ) ;
8989 } catch ( e ) {
9090 Logger . appendLine ( `Error in initialization: ${ e . message } ` , TemporaryState . ID ) ;
9191 }
9292 try {
93- await vscode . workspace . fs . createDirectory ( tempState . _path ) ;
94- } catch ( e ) {
95- Logger . appendLine ( `Error in initialization: ${ e . message } ` , TemporaryState . ID ) ;
96- }
97- context . subscriptions . push ( tempState ) ;
98- return tempState ;
99- }
100- }
101-
102- static async write ( subpath : string , filename : string , contents : Uint8Array , persistInSession : boolean = false ) : Promise < vscode . Uri | undefined > {
103- if ( ! tempState ) {
104- return ;
105- }
106-
107- return tempState . _writeState ( subpath , filename , contents , persistInSession ) ;
108- }
109-
110- static async read ( subpath : string , filename : string ) : Promise < Uint8Array | undefined > {
111- if ( ! tempState ) {
112- return ;
113- }
114-
115- return tempState . _readState ( subpath , filename ) ;
93+ await vscode . workspace . fs . createDirectory ( tempState . _path ) ;
94+ } catch ( e ) {
95+ Logger . appendLine ( `Error in initialization: ${ e . message } ` , TemporaryState . ID ) ;
96+ }
97+ context . subscriptions . push ( tempState ) ;
98+ return tempState ;
99+ }
100+ }
101+
102+ static async write ( subpath : string , filename : string , contents : Uint8Array , persistInSession : boolean = false ) : Promise < vscode . Uri | undefined > {
103+ if ( ! tempState ) {
104+ return ;
105+ }
106+
107+ return tempState . _writeState ( subpath , filename , contents , persistInSession ) ;
108+ }
109+
110+ static async read ( subpath : string , filename : string ) : Promise < Uint8Array | undefined > {
111+ if ( ! tempState ) {
112+ return ;
113+ }
114+
115+ return tempState . _readState ( subpath , filename ) ;
116116 }
117117}
0 commit comments