Skip to content

Commit 32f9af9

Browse files
committed
Introduced cancellation on reparse in the tests.
1 parent 0d5cc6b commit 32f9af9

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Rubberduck.Parsing/VBA/ParseCoordinator.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ private void ReparseRequested(object sender, EventArgs e)
8080
}
8181
else
8282
{
83-
Parse(_cancellationTokens[0]);
83+
Cancel();
84+
ParseInternal(_cancellationTokens[0]);
8485
}
8586
}
8687

@@ -101,7 +102,28 @@ private void Cancel(bool createNewTokenSource = true)
101102
/// <summary>
102103
/// For the use of tests only
103104
/// </summary>
105+
///
104106
public void Parse(CancellationTokenSource token)
107+
{
108+
SetSavedCancellationTokenSource(token);
109+
ParseInternal(token);
110+
}
111+
112+
private void SetSavedCancellationTokenSource(CancellationTokenSource token)
113+
{
114+
if (_cancellationTokens.Any())
115+
{
116+
_cancellationTokens[0].Cancel();
117+
_cancellationTokens[0].Dispose();
118+
_cancellationTokens[0] = token;
119+
}
120+
else
121+
{
122+
_cancellationTokens.Add(token);
123+
}
124+
}
125+
126+
private void ParseInternal(CancellationTokenSource token)
105127
{
106128
State.RefreshProjects(_vbe);
107129

0 commit comments

Comments
 (0)