Skip to content

Commit 5befcf9

Browse files
Remove usage of WaitAndGetResult from debugger paths
1 parent 6f8ea71 commit 5befcf9

File tree

1 file changed

+30
-32
lines changed

1 file changed

+30
-32
lines changed

src/VisualStudio/Core/Def/LanguageService/AbstractLanguageService`2.VsLanguageDebugInfo.cs

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -133,47 +133,45 @@ public int GetNameOfLocation(IVsTextBuffer pBuffer, int iLine, int iCol, out str
133133

134134
public int GetProximityExpressions(IVsTextBuffer pBuffer, int iLine, int iCol, int cLines, out IVsEnumBSTR? ppEnum)
135135
{
136-
// NOTE(cyrusn): cLines is ignored. This is to match existing dev10 behavior.
137-
using (Logger.LogBlock(FunctionId.Debugging_VsLanguageDebugInfo_GetProximityExpressions, CancellationToken.None))
136+
ppEnum = _threadingContext.JoinableTaskFactory.Run(async () =>
138137
{
139-
VsEnumBSTR? enumBSTR = null;
140-
141-
if (_proximityExpressionsService != null)
138+
// NOTE(cyrusn): cLines is ignored. This is to match existing dev10 behavior.
139+
using (Logger.LogBlock(FunctionId.Debugging_VsLanguageDebugInfo_GetProximityExpressions, CancellationToken.None))
142140
{
143-
_uiThreadOperationExecutor.Execute(
141+
using var context = _uiThreadOperationExecutor.BeginExecute(
144142
title: ServicesVSResources.Debugger,
145143
defaultDescription: ServicesVSResources.Determining_autos,
146144
allowCancellation: true,
147-
showProgress: false,
148-
action: context =>
149-
{
150-
var textBuffer = _languageService.EditorAdaptersFactoryService.GetDataBuffer(pBuffer);
145+
showProgress: false);
151146

152-
if (textBuffer != null)
153-
{
154-
var snapshot = textBuffer.CurrentSnapshot;
155-
var nullablePoint = snapshot.TryGetPoint(iLine, iCol);
156-
if (nullablePoint.HasValue)
157-
{
158-
var document = snapshot.GetOpenDocumentInCurrentContextWithChanges();
159-
if (document != null)
160-
{
161-
var point = nullablePoint.Value;
162-
var proximityExpressions = _proximityExpressionsService.GetProximityExpressionsAsync(document, point.Position, context.UserCancellationToken).WaitAndGetResult(context.UserCancellationToken);
147+
if (_proximityExpressionsService == null)
148+
return null;
163149

164-
if (proximityExpressions != null)
165-
{
166-
enumBSTR = new VsEnumBSTR(proximityExpressions);
167-
}
168-
}
169-
}
170-
}
171-
});
150+
var textBuffer = _languageService.EditorAdaptersFactoryService.GetDataBuffer(pBuffer);
151+
if (textBuffer == null)
152+
return null;
153+
154+
var snapshot = textBuffer.CurrentSnapshot;
155+
var nullablePoint = snapshot.TryGetPoint(iLine, iCol);
156+
if (!nullablePoint.HasValue)
157+
return null;
158+
159+
var document = snapshot.GetOpenDocumentInCurrentContextWithChanges();
160+
if (document == null)
161+
return null;
162+
163+
var point = nullablePoint.Value;
164+
var proximityExpressions = await _proximityExpressionsService.GetProximityExpressionsAsync(
165+
document, point.Position, context.UserCancellationToken).ConfigureAwait(true);
166+
167+
if (proximityExpressions == null)
168+
return null;
169+
170+
return new VsEnumBSTR(proximityExpressions);
172171
}
172+
});
173173

174-
ppEnum = enumBSTR;
175-
return ppEnum != null ? VSConstants.S_OK : VSConstants.E_FAIL;
176-
}
174+
return ppEnum != null ? VSConstants.S_OK : VSConstants.E_FAIL;
177175
}
178176

179177
public int IsMappedLocation(IVsTextBuffer pBuffer, int iLine, int iCol)

0 commit comments

Comments
 (0)