Skip to content

Commit 86db27e

Browse files
committed
Add mechanism to report status of reparse requests that are canceled before reparse is requested. Closes #4562
1 parent 020cb20 commit 86db27e

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

Rubberduck.Core/UI/Command/ReparseCommand.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515

1616
namespace Rubberduck.UI.Command
1717
{
18+
[ComVisible(false)]
19+
public class ReparseCancellationFlag
20+
{
21+
public bool Canceled { get; set; }
22+
}
23+
1824
[ComVisible(false)]
1925
public class ReparseCommand : CommandBase
2026
{
@@ -50,13 +56,21 @@ protected override void OnExecute(object parameter)
5056
{
5157
if (!VerifyCompileOnDemand())
5258
{
59+
if (parameter is ReparseCancellationFlag cancellation)
60+
{
61+
cancellation.Canceled = true;
62+
}
5363
return;
5464
}
5565

5666
if (AreAllProjectsCompiled(out var failedNames))
5767
{
5868
if (!PromptUserToContinue(failedNames))
5969
{
70+
if (parameter is ReparseCancellationFlag cancellation)
71+
{
72+
cancellation.Canceled = true;
73+
}
6074
return;
6175
}
6276
}

Rubberduck.Core/UI/Inspections/InspectionResultsViewModel.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ public InspectionResultsViewModel(
9494
{
9595
IsRefreshing = true;
9696
IsBusy = true;
97-
reparseCommand.Execute(o);
97+
var cancellation = new ReparseCancellationFlag();
98+
reparseCommand.Execute(cancellation);
99+
if (cancellation.Canceled)
100+
{
101+
IsBusy = false;
102+
}
98103
},
99104
o => !IsBusy && reparseCommand.CanExecute(o));
100105

@@ -340,8 +345,6 @@ public bool Unparsed
340345
private bool _runInspectionsOnReparse;
341346
private void HandleStateChanged(object sender, ParserStateEventArgs e)
342347
{
343-
Unparsed = false;
344-
345348
if (!IsRefreshing && (_state.Status == ParserState.Pending || _state.Status == ParserState.Error || _state.Status == ParserState.ResolverError))
346349
{
347350
IsBusy = false;
@@ -391,6 +394,8 @@ private async void RefreshInspections(CancellationToken token)
391394
stopwatch.Stop();
392395
LogManager.GetCurrentClassLogger().Trace("Inspection results returned in {0}ms", stopwatch.ElapsedMilliseconds);
393396

397+
Unparsed = false;
398+
394399
_uiDispatcher.Invoke(() =>
395400
{
396401
stopwatch = Stopwatch.StartNew();

0 commit comments

Comments
 (0)