提交 d1a932d4 编写于 作者: C CyrusNajmabadi

Fix crash in lightbulbs in projection scenarios.

A previous change of mine moved it so that we try to grab the user's selectoin as the first
thing we do when queried in lightbulbs.  This was to make it so we would not call back into
the UI thread from a BG thread.  Unfortunately, the code i moved was not safe to call if the
query was a projection buffer.  This wasn't a problem previously because there was a prior
check that ran that would cause us to bail out.

I've now reordered things so that the check comes first, and then we get the selection afterwards.
上级 bcdcafc2
......@@ -640,8 +640,18 @@ private static SuggestedActionSetPriority GetSuggestedActionSetPriority(CodeActi
using (var asyncToken = _owner.OperationListener.BeginAsyncOperation("HasSuggestedActionsAsync"))
{
// Acquire the user's selection up front, before we do any async work, so that we can
// directly grab it when we're on the UI thread. That way we don't have any reentrancy
// First, ensure that the snapshot we're being asked about is for an actual
// roslyn document. This can fail, for example, in projection scenarios where
// we are called with a range snapshot that refers to the projection buffer
// and not the actual roslyn code that is being projected into it.
var document = range.Snapshot.GetOpenDocumentInCurrentContextWithChanges();
if (document == null)
{
return false;
}
// Next, before we do any async work, acquire the user's selection, directly grabbing
// it from the UI thread if htat's what we're on. That way we don't have any reentrancy
// blocking concerns if VS wants to block on this call (for example, if the user
// explicitly invokes the 'show smart tag' command).
//
......@@ -684,14 +694,6 @@ private static SuggestedActionSetPriority GetSuggestedActionSetPriority(CodeActi
}).ConfigureAwait(false);
}
var document = range.Snapshot.GetOpenDocumentInCurrentContextWithChanges();
if (document == null)
{
// this is here to fail test and see why it is failed.
Trace.WriteLine("given range is not current");
return false;
}
return
await HasFixesAsync(provider, document, range, cancellationToken).ConfigureAwait(false) ||
await HasRefactoringsAsync(provider, document, selection, cancellationToken).ConfigureAwait(false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册