Skip to content

Commit a6eb196

Browse files
committed
Check that the VBE is in design mode when handling sinks
1 parent 5ac30ca commit a6eb196

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

RetailCoder.VBE/App.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System.Threading.Tasks;
2020
using System.Windows.Forms;
2121
using Rubberduck.UI.SourceControl;
22+
using Rubberduck.VBEditor.Extensions;
2223

2324
namespace Rubberduck
2425
{
@@ -216,7 +217,7 @@ public void Shutdown()
216217
#region sink handlers. todo: move to another class
217218
async void sink_ProjectRemoved(object sender, DispatcherEventArgs<VBProject> e)
218219
{
219-
if (!_handleSinkEvents) { return; }
220+
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
220221

221222
if (e.Item.Protection == vbext_ProjectProtection.vbext_pp_locked)
222223
{
@@ -256,7 +257,7 @@ async void sink_ProjectRemoved(object sender, DispatcherEventArgs<VBProject> e)
256257

257258
async void sink_ProjectAdded(object sender, DispatcherEventArgs<VBProject> e)
258259
{
259-
if (!_handleSinkEvents) { return; }
260+
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
260261

261262
_logger.Debug("Project '{0}' was added.", e.Item.Name);
262263
if (e.Item.Protection == vbext_ProjectProtection.vbext_pp_locked)
@@ -313,7 +314,7 @@ private void RegisterComponentsEventSink(VBComponents components, string project
313314

314315
async void sink_ComponentSelected(object sender, DispatcherEventArgs<VBComponent> e)
315316
{
316-
if (!_handleSinkEvents) { return; }
317+
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
317318

318319
if (!_parser.State.AllDeclarations.Any())
319320
{
@@ -326,7 +327,7 @@ async void sink_ComponentSelected(object sender, DispatcherEventArgs<VBComponent
326327

327328
async void sink_ComponentRenamed(object sender, DispatcherRenamedEventArgs<VBComponent> e)
328329
{
329-
if (!_handleSinkEvents) { return; }
330+
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
330331

331332
if (!_parser.State.AllDeclarations.Any())
332333
{
@@ -342,7 +343,7 @@ async void sink_ComponentRenamed(object sender, DispatcherRenamedEventArgs<VBCom
342343

343344
async void sink_ComponentRemoved(object sender, DispatcherEventArgs<VBComponent> e)
344345
{
345-
if (!_handleSinkEvents) { return; }
346+
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
346347

347348
if (!_parser.State.AllDeclarations.Any())
348349
{
@@ -357,7 +358,7 @@ async void sink_ComponentRemoved(object sender, DispatcherEventArgs<VBComponent>
357358

358359
async void sink_ComponentReloaded(object sender, DispatcherEventArgs<VBComponent> e)
359360
{
360-
if (!_handleSinkEvents) { return; }
361+
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
361362

362363
if (!_parser.State.AllDeclarations.Any())
363364
{
@@ -370,7 +371,7 @@ async void sink_ComponentReloaded(object sender, DispatcherEventArgs<VBComponent
370371

371372
async void sink_ComponentAdded(object sender, DispatcherEventArgs<VBComponent> e)
372373
{
373-
if (!_handleSinkEvents) { return; }
374+
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
374375

375376
if (!_parser.State.AllDeclarations.Any())
376377
{
@@ -385,7 +386,7 @@ async void sink_ComponentAdded(object sender, DispatcherEventArgs<VBComponent> e
385386

386387
async void sink_ComponentActivated(object sender, DispatcherEventArgs<VBComponent> e)
387388
{
388-
if (!_handleSinkEvents) { return; }
389+
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
389390

390391
if (!_parser.State.AllDeclarations.Any())
391392
{
@@ -398,7 +399,7 @@ async void sink_ComponentActivated(object sender, DispatcherEventArgs<VBComponen
398399

399400
async void sink_ProjectRenamed(object sender, DispatcherRenamedEventArgs<VBProject> e)
400401
{
401-
if (!_handleSinkEvents) { return; }
402+
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
402403

403404
if (!_parser.State.AllDeclarations.Any())
404405
{
@@ -415,7 +416,7 @@ async void sink_ProjectRenamed(object sender, DispatcherRenamedEventArgs<VBProje
415416

416417
async void sink_ProjectActivated(object sender, DispatcherEventArgs<VBProject> e)
417418
{
418-
if (!_handleSinkEvents) { return; }
419+
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
419420

420421
if (!_parser.State.AllDeclarations.Any())
421422
{

0 commit comments

Comments
 (0)