@@ -107,26 +107,26 @@ public void AddComponent(VBComponent component)
107
107
{
108
108
if ( Provider == null ) { return ; }
109
109
110
- _fileSystemWatcher . EnableRaisingEvents = false ;
110
+ // _fileSystemWatcher.EnableRaisingEvents = false;
111
111
var fileStatus = Provider . Status ( ) . SingleOrDefault ( stat => stat . FilePath . Split ( '.' ) [ 0 ] == component . Name ) ;
112
112
if ( fileStatus != null )
113
113
{
114
114
Provider . AddFile ( fileStatus . FilePath ) ;
115
115
}
116
- _fileSystemWatcher . EnableRaisingEvents = true ;
116
+ // _fileSystemWatcher.EnableRaisingEvents = true;
117
117
}
118
118
119
119
public void RemoveComponent ( VBComponent component )
120
120
{
121
121
if ( Provider == null ) { return ; }
122
122
123
- _fileSystemWatcher . EnableRaisingEvents = false ;
123
+ // _fileSystemWatcher.EnableRaisingEvents = false;
124
124
var fileStatus = Provider . Status ( ) . SingleOrDefault ( stat => stat . FilePath . Split ( '.' ) [ 0 ] == component . Name ) ;
125
125
if ( fileStatus != null )
126
126
{
127
127
Provider . RemoveFile ( fileStatus . FilePath , true ) ;
128
128
}
129
- _fileSystemWatcher . EnableRaisingEvents = true ;
129
+ // _fileSystemWatcher.EnableRaisingEvents = true;
130
130
}
131
131
132
132
public void RenameComponent ( VBComponent component , string oldName )
@@ -136,17 +136,17 @@ public void RenameComponent(VBComponent component, string oldName)
136
136
var fileStatus = Provider . LastKnownStatus ( ) . SingleOrDefault ( stat => stat . FilePath . Split ( '.' ) [ 0 ] == oldName ) ;
137
137
if ( fileStatus != null )
138
138
{
139
- _fileSystemWatcher . EnableRaisingEvents = false ;
140
139
var directory = Provider . CurrentRepository . LocalLocation ;
141
140
directory += directory . EndsWith ( "\\ " ) ? string . Empty : "\\ " ;
142
141
143
142
var fileExt = "." + fileStatus . FilePath . Split ( '.' ) . Last ( ) ;
144
143
144
+ _fileSystemWatcher . EnableRaisingEvents = false ;
145
145
File . Move ( directory + fileStatus . FilePath , directory + component . Name + fileExt ) ;
146
+ _fileSystemWatcher . EnableRaisingEvents = true ;
147
+
146
148
Provider . RemoveFile ( oldName + fileExt , false ) ;
147
149
Provider . AddFile ( component . Name + fileExt ) ;
148
-
149
- _fileSystemWatcher . EnableRaisingEvents = true ;
150
150
}
151
151
}
152
152
@@ -174,9 +174,6 @@ public ISourceControlProvider Provider
174
174
_provider = value ;
175
175
SetChildPresenterSourceControlProviders ( _provider ) ;
176
176
177
- Provider . ExportFilesStarted += Provider_ExportFilesStarted ;
178
- Provider . ExportFilesCompleted += Provider_ExportFilesCompleted ;
179
-
180
177
if ( _fileSystemWatcher . Path != LocalDirectory && Directory . Exists ( _provider . CurrentRepository . LocalLocation ) )
181
178
{
182
179
_fileSystemWatcher . Path = _provider . CurrentRepository . LocalLocation ;
@@ -191,16 +188,6 @@ public ISourceControlProvider Provider
191
188
}
192
189
}
193
190
194
- private void Provider_ExportFilesCompleted ( object sender , EventArgs e )
195
- {
196
- _fileSystemWatcher . EnableRaisingEvents = true ;
197
- }
198
-
199
- private void Provider_ExportFilesStarted ( object sender , EventArgs e )
200
- {
201
- _fileSystemWatcher . EnableRaisingEvents = false ;
202
- }
203
-
204
191
private void _fileSystemWatcher_Changed ( object sender , FileSystemEventArgs e )
205
192
{
206
193
// the file system filter doesn't support multiple filters
@@ -209,6 +196,11 @@ private void _fileSystemWatcher_Changed(object sender, FileSystemEventArgs e)
209
196
return ;
210
197
}
211
198
199
+ if ( ! Provider . NotifyExternalFileChanges )
200
+ {
201
+ return ;
202
+ }
203
+
212
204
Logger . Trace ( "File system watcher detected file changed" ) ;
213
205
if ( _messageBox . Show ( "file changed" , RubberduckUI . SourceControlPanel_Caption ,
214
206
MessageBoxButtons . OKCancel , MessageBoxIcon . Information , MessageBoxDefaultButton . Button1 ) == DialogResult . OK )
@@ -225,6 +217,11 @@ private void _fileSystemWatcher_Renamed(object sender, RenamedEventArgs e)
225
217
return ;
226
218
}
227
219
220
+ if ( ! Provider . NotifyExternalFileChanges )
221
+ {
222
+ return ;
223
+ }
224
+
228
225
Logger . Trace ( "File system watcher detected file renamed" ) ;
229
226
if ( _messageBox . Show ( "file changed" , RubberduckUI . SourceControlPanel_Caption ,
230
227
MessageBoxButtons . OKCancel , MessageBoxIcon . Information , MessageBoxDefaultButton . Button1 ) == DialogResult . OK )
@@ -243,6 +240,11 @@ private void _fileSystemWatcher_Deleted(object sender, FileSystemEventArgs e)
243
240
return ;
244
241
}
245
242
243
+ if ( ! Provider . NotifyExternalFileChanges )
244
+ {
245
+ return ;
246
+ }
247
+
246
248
Logger . Trace ( "File system watcher detected file deleted" ) ;
247
249
if ( _messageBox . Show ( "file changed" , RubberduckUI . SourceControlPanel_Caption ,
248
250
MessageBoxButtons . OKCancel , MessageBoxIcon . Information , MessageBoxDefaultButton . Button1 ) == DialogResult . OK )
@@ -260,6 +262,11 @@ private void _fileSystemWatcher_Created(object sender, FileSystemEventArgs e)
260
262
return ;
261
263
}
262
264
265
+ if ( ! Provider . NotifyExternalFileChanges )
266
+ {
267
+ return ;
268
+ }
269
+
263
270
Logger . Trace ( "File system watcher detected file created" ) ;
264
271
if ( _messageBox . Show ( "file changed" , RubberduckUI . SourceControlPanel_Caption ,
265
272
MessageBoxButtons . OKCancel , MessageBoxIcon . Information , MessageBoxDefaultButton . Button1 ) == DialogResult . OK )
0 commit comments