提交 d0c96a79 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #14459 from CyrusNajmabadi/nullTextViewLinesRC

Be resilient to being called while the text view is being initialized.
......@@ -106,7 +106,8 @@ internal static class SemanticClassificationUtilities
return true;
}
private static async Task ClassifySpansAsync(TaggerContext<IClassificationTag> context, DocumentSnapshotSpan spanToTag,
private static async Task ClassifySpansAsync(
TaggerContext<IClassificationTag> context, DocumentSnapshotSpan spanToTag,
IEditorClassificationService classificationService, ClassificationTypeMap typeMap)
{
try
......
......@@ -326,6 +326,12 @@ public static bool TryMoveCaretToAndEnsureVisible(this ITextView textView, Virtu
/// </summary>
public static SnapshotSpan? GetVisibleLinesSpan(this ITextView textView, ITextBuffer subjectBuffer, int extraLines = 0)
{
// No point in continuing if the text view has been closed.
if (textView.IsClosed)
{
return null;
}
// If we're being called while the textview is actually in the middle of a layout, then
// we can't proceed. Much of the text view state is unsafe to access (and will throw).
if (textView.InLayout)
......@@ -333,6 +339,13 @@ public static bool TryMoveCaretToAndEnsureVisible(this ITextView textView, Virtu
return null;
}
// During text view initialization the TextViewLines may be null. In that case we can't
// get an appropriate visisble span.
if (textView.TextViewLines == null)
{
return null;
}
// Determine the range of text that is visible in the view. Then map this down to the
// bufffer passed in. From that, determine the start/end line for the buffer that is in
// view.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册