@@ -10,37 +10,37 @@ let tempState: TemporaryState | undefined;
1010
1111export class TemporaryState extends vscode . Disposable {
1212 static readonly ID = 'TemporaryState' ;
13- private readonly SUBPATH = 'temp' ;
14- private readonly disposables : vscode . Disposable [ ] = [ ] ;
15- private readonly persistInSessionDisposables : vscode . Disposable [ ] = [ ] ;
13+ private readonly _SUBPATH = 'temp' ;
14+ private readonly _disposables : vscode . Disposable [ ] = [ ] ;
15+ private readonly _persistInSessionDisposables : vscode . Disposable [ ] = [ ] ;
1616
17- constructor ( private readonly _storageUri : vscode . Uri ) {
18- super ( ( ) => disposeAll ( this . disposables ) ) ;
17+ constructor ( private readonly _storageUri : vscode . Uri ) {
18+ super ( ( ) => disposeAll ( this . _disposables ) ) ;
1919 }
2020
21- private get path ( ) : vscode . Uri {
22- return vscode . Uri . joinPath ( this . _storageUri , this . SUBPATH ) ;
21+ private get _path ( ) : vscode . Uri {
22+ return vscode . Uri . joinPath ( this . _storageUri , this . _SUBPATH ) ;
2323 }
2424
25- override dispose ( ) {
26- disposeAll ( this . disposables ) ;
27- disposeAll ( this . persistInSessionDisposables ) ;
25+ override dispose ( ) {
26+ disposeAll ( this . _disposables ) ;
27+ disposeAll ( this . _persistInSessionDisposables ) ;
2828 }
2929
30- private addDisposable ( disposable : vscode . Disposable , persistInSession : boolean ) {
31- if ( persistInSession ) {
32- this . persistInSessionDisposables . push ( disposable ) ;
33- } else {
34- if ( this . disposables . length > 30 ) {
35- const oldDisposable = this . disposables . shift ( ) ;
36- oldDisposable ?. dispose ( ) ;
37- }
38- this . disposables . push ( disposable ) ;
39- }
30+ private _addDisposable ( disposable : vscode . Disposable , persistInSession : boolean ) {
31+ if ( persistInSession ) {
32+ this . _persistInSessionDisposables . push ( disposable ) ;
33+ } else {
34+ if ( this . _disposables . length > 30 ) {
35+ const oldDisposable = this . _disposables . shift ( ) ;
36+ oldDisposable ?. dispose ( ) ;
37+ }
38+ this . _disposables . push ( disposable ) ;
39+ }
4040 }
4141
42- private async writeState ( subpath : string , filename : string , contents : Uint8Array , persistInSession : boolean ) : Promise < vscode . Uri > {
43- let filePath : vscode . Uri = this . path ;
42+ private async _writeState ( subpath : string , filename : string , contents : Uint8Array , persistInSession : boolean ) : Promise < vscode . Uri > {
43+ let filePath : vscode . Uri = this . _path ;
4444 const workspace = ( vscode . workspace . workspaceFolders && vscode . workspace . workspaceFolders . length > 0 )
4545 ? vscode . workspace . workspaceFolders [ 0 ] . name : undefined ;
4646
@@ -64,12 +64,12 @@ export class TemporaryState extends vscode.Disposable {
6464 }
6565 }
6666 } ;
67- this . addDisposable ( dispose , persistInSession ) ;
67+ this . _addDisposable ( dispose , persistInSession ) ;
6868 return file ;
6969 }
7070
71- private async readState ( subpath : string , filename : string ) : Promise < Uint8Array > {
72- let filePath : vscode . Uri = this . path ;
71+ private async _readState ( subpath : string , filename : string ) : Promise < Uint8Array > {
72+ let filePath : vscode . Uri = this . _path ;
7373 const workspace = ( vscode . workspace . workspaceFolders && vscode . workspace . workspaceFolders . length > 0 )
7474 ? vscode . workspace . workspaceFolders [ 0 ] . name : undefined ;
7575
@@ -84,13 +84,13 @@ export class TemporaryState extends vscode.Disposable {
8484 static async init ( context : vscode . ExtensionContext ) : Promise < vscode . Disposable | undefined > {
8585 if ( context . globalStorageUri && ! tempState ) {
8686 tempState = new TemporaryState ( context . globalStorageUri ) ;
87- try {
88- await vscode . workspace . fs . delete ( tempState . path , { recursive : true } ) ;
89- } catch ( e ) {
90- Logger . appendLine ( `Error in initialization: ${ e . message } ` , TemporaryState . ID ) ;
91- }
92- try {
93- await vscode . workspace . fs . createDirectory ( tempState . path ) ;
87+ try {
88+ await vscode . workspace . fs . delete ( tempState . _path , { recursive : true } ) ;
89+ } catch ( e ) {
90+ Logger . appendLine ( `Error in initialization: ${ e . message } ` , TemporaryState . ID ) ;
91+ }
92+ try {
93+ await vscode . workspace . fs . createDirectory ( tempState . _path ) ;
9494 } catch ( e ) {
9595 Logger . appendLine ( `Error in initialization: ${ e . message } ` , TemporaryState . ID ) ;
9696 }
@@ -104,14 +104,14 @@ export class TemporaryState extends vscode.Disposable {
104104 return ;
105105 }
106106
107- return tempState . writeState ( subpath , filename , contents , persistInSession ) ;
107+ return tempState . _writeState ( subpath , filename , contents , persistInSession ) ;
108108 }
109109
110110 static async read ( subpath : string , filename : string ) : Promise < Uint8Array | undefined > {
111111 if ( ! tempState ) {
112112 return ;
113113 }
114114
115- return tempState . readState ( subpath , filename ) ;
115+ return tempState . _readState ( subpath , filename ) ;
116116 }
117117}
0 commit comments