@@ -23,6 +23,8 @@ export class Model {
23
23
private ignorePattern : RegExp = / ^ $ / ;
24
24
private maxDepth : number = 0 ;
25
25
26
+ private configurationChangeDisposable : Disposable ;
27
+
26
28
get repositories ( ) : Repository [ ] {
27
29
return this . openRepositories . map ( r => r . repository ) ;
28
30
}
@@ -31,39 +33,61 @@ export class Model {
31
33
const config = workspace . getConfiguration ( "svn" ) ;
32
34
this . enabled = config . get ( "enabled" ) === true ;
33
35
36
+ this . configurationChangeDisposable = workspace . onDidChangeConfiguration (
37
+ this . onDidChangeConfiguration ,
38
+ this
39
+ ) ;
40
+
34
41
if ( this . enabled ) {
35
- this . init ( ) ;
36
-
37
- const multipleFolders = config . get < boolean > (
38
- "multipleFolders.enabled" ,
39
- false
40
- ) ;
41
-
42
- if ( multipleFolders ) {
43
- this . maxDepth = config . get < number > ( "multipleFolders.depth" , 0 ) ;
44
-
45
- const ignoreList = config . get ( "multipleFolders.ignore" , [ ] ) ;
46
-
47
- // Base on https://github.com/aleclarson/glob-regex/blob/master/index.js
48
- const pattern = ignoreList
49
- . join ( "|" )
50
- . replace ( / \. / g, "\\." )
51
- . replace ( / \* \* \/ / g, "(.+[\\\\\/])?" )
52
- . replace ( / \* \* / g, "(.+[\\\\\/])?*" )
53
- . replace ( / \* / g, "[^\\\\\/]+" ) ;
54
-
55
- try {
56
- this . ignorePattern = new RegExp ( "^(" + pattern + ")$" ) ;
57
- } catch ( error ) {
58
- window . showErrorMessage ( "Invalid pattern for: " + pattern ) ;
59
- }
60
- }
42
+ this . enable ( ) ;
43
+ }
44
+ }
45
+
46
+ private onDidChangeConfiguration ( ) : void {
47
+ const config = workspace . getConfiguration ( "svn" ) ;
48
+ const enabled = config . get ( "enabled" ) === true ;
49
+
50
+ if ( enabled === this . enabled ) {
51
+ return ;
52
+ }
53
+
54
+ this . enabled = enabled ;
55
+
56
+ if ( enabled ) {
57
+ this . enable ( ) ;
61
58
} else {
62
59
this . disable ( ) ;
63
60
}
64
61
}
65
62
66
- private init ( ) : void {
63
+ private enable ( ) : void {
64
+ const config = workspace . getConfiguration ( "svn" ) ;
65
+
66
+ const multipleFolders = config . get < boolean > (
67
+ "multipleFolders.enabled" ,
68
+ false
69
+ ) ;
70
+
71
+ if ( multipleFolders ) {
72
+ this . maxDepth = config . get < number > ( "multipleFolders.depth" , 0 ) ;
73
+
74
+ const ignoreList = config . get ( "multipleFolders.ignore" , [ ] ) ;
75
+
76
+ // Base on https://github.com/aleclarson/glob-regex/blob/master/index.js
77
+ const pattern = ignoreList
78
+ . join ( "|" )
79
+ . replace ( / \. / g, "\\." )
80
+ . replace ( / \* \* \/ / g, "(.+[\\\\/])?" )
81
+ . replace ( / \* \* / g, "(.+[\\\\/])?*" )
82
+ . replace ( / \* / g, "[^\\\\/]+" ) ;
83
+
84
+ try {
85
+ this . ignorePattern = new RegExp ( "^(" + pattern + ")$" ) ;
86
+ } catch ( error ) {
87
+ window . showErrorMessage ( "Invalid pattern for: " + pattern ) ;
88
+ }
89
+ }
90
+
67
91
workspace . onDidChangeWorkspaceFolders (
68
92
this . onDidChangeWorkspaceFolders ,
69
93
this ,
@@ -112,6 +136,8 @@ export class Model {
112
136
private disable ( ) : void {
113
137
this . repositories . forEach ( repository => repository . dispose ( ) ) ;
114
138
this . openRepositories = [ ] ;
139
+
140
+ this . possibleSvnRepositoryPaths . clear ( ) ;
115
141
this . disposables = dispose ( this . disposables ) ;
116
142
}
117
143
@@ -246,5 +272,8 @@ export class Model {
246
272
return pick && pick . repository ;
247
273
}
248
274
249
- dispose ( ) : void { }
275
+ dispose ( ) : void {
276
+ this . disable ( ) ;
277
+ this . configurationChangeDisposable . dispose ( ) ;
278
+ }
250
279
}
0 commit comments