@@ -5,18 +5,26 @@ import {
5
5
FileSystemWatcher ,
6
6
SourceControl ,
7
7
SourceControlResourceGroup ,
8
- SourceControlInputBox
8
+ SourceControlInputBox ,
9
+ Disposable ,
10
+ EventEmitter ,
11
+ Event
9
12
} from "vscode" ;
10
13
import { Resource } from "./resource" ;
11
14
import { throttleAsync } from "./decorators" ;
12
15
import { Repository as BaseRepository } from "./svn" ;
13
16
import { SvnStatusBar } from "./statusBar" ;
17
+ import { dispose } from "./util" ;
14
18
15
19
export class Repository {
16
20
public watcher : FileSystemWatcher ;
17
21
private sourceControl : SourceControl ;
18
22
public changes : SourceControlResourceGroup ;
19
23
public notTracked : SourceControlResourceGroup ;
24
+ private disposables : Disposable [ ] = [ ] ;
25
+
26
+ private _onDidChangeStatus = new EventEmitter < void > ( ) ;
27
+ readonly onDidChangeStatus : Event < void > = this . _onDidChangeStatus . event ;
20
28
21
29
get root ( ) : string {
22
30
return this . repository . root ;
@@ -32,6 +40,8 @@ export class Repository {
32
40
33
41
constructor ( public repository : BaseRepository ) {
34
42
this . watcher = workspace . createFileSystemWatcher ( "**" ) ;
43
+ this . disposables . push ( this . watcher ) ;
44
+
35
45
this . sourceControl = scm . createSourceControl (
36
46
"svn" ,
37
47
"SVN" ,
@@ -43,9 +53,16 @@ export class Repository {
43
53
arguments : [ this . sourceControl ]
44
54
} ;
45
55
this . sourceControl . quickDiffProvider = this ;
46
-
47
- const test = new SvnStatusBar ( this ) ;
48
- this . sourceControl . statusBarCommands = test . commands ;
56
+ this . disposables . push ( this . sourceControl ) ;
57
+
58
+ const statusBar = new SvnStatusBar ( this ) ;
59
+ this . disposables . push ( statusBar ) ;
60
+ statusBar . onDidChange (
61
+ ( ) => ( this . sourceControl . statusBarCommands = statusBar . commands ) ,
62
+ null ,
63
+ this . disposables
64
+ ) ;
65
+ this . sourceControl . statusBarCommands = statusBar . commands ;
49
66
50
67
this . changes = this . sourceControl . createResourceGroup ( "changes" , "Changes" ) ;
51
68
this . notTracked = this . sourceControl . createResourceGroup (
@@ -111,6 +128,8 @@ export class Repository {
111
128
this . changes . resourceStates = changes ;
112
129
this . notTracked . resourceStates = notTracked ;
113
130
131
+ this . _onDidChangeStatus . fire ( ) ;
132
+
114
133
return Promise . resolve ( ) ;
115
134
}
116
135
@@ -132,4 +151,8 @@ export class Repository {
132
151
addFile ( filePath : string ) {
133
152
return this . repository . addFile ( filePath ) ;
134
153
}
154
+
155
+ dispose ( ) : void {
156
+ this . disposables = dispose ( this . disposables ) ;
157
+ }
135
158
}
0 commit comments