Skip to content

Commit e86d462

Browse files
committed
Fix the logic for setting the completed state of the suspension result and fix a bad unit test.
1 parent 9b9d7ee commit e86d462

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Rubberduck.Parsing/VBA/ParseCoordinator.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ public void SuspendRequested(object sender, RubberduckStatusSuspendParserEventAr
132132
CancellationToken.None);
133133
e.BusyAction.Invoke();
134134
}
135+
catch
136+
{
137+
e.Result = SuspensionResult.UnexpectedError;
138+
throw;
139+
}
135140
finally
136141
{
137142
lock (SuspendStackSyncObject)
@@ -153,13 +158,17 @@ public void SuspendRequested(object sender, RubberduckStatusSuspendParserEventAr
153158
// evaluation to the state manager.
154159
_parserStateManager.EvaluateOverallParserState(CancellationToken.None);
155160
}
156-
e.Result = SuspensionResult.Completed;
157161
}
158162

159163
if (ParsingSuspendLock.IsWriteLockHeld)
160164
{
161165
ParsingSuspendLock.ExitWriteLock();
162166
}
167+
168+
if (e.Result == SuspensionResult.Pending)
169+
{
170+
e.Result = SuspensionResult.Completed;
171+
}
163172
}
164173

165174
// Any reparse requests must be done outside the write lock to avoid deadlocks

RubberduckTests/ParserState/ParserStateTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public void Test_RPS_SuspendParser_Interrupted_Deadlock()
242242
result2.Wait(token);
243243
}
244244
Assert.IsFalse(wasSuspended, "wasSuspended was set to true");
245-
Assert.AreEqual(SuspensionResult.Completed, result);
245+
Assert.AreEqual(SuspensionResult.TimedOut, result);
246246
}
247247

248248
[Test]

0 commit comments

Comments
 (0)