提交 531aa3cc 编写于 作者: H Heejae Chang

fixed a crash where diagnostic source is removed but asked new snapshot from...

fixed a crash where diagnostic source is removed but asked new snapshot from error list in two different snapshot
上级 522e1e0d
......@@ -6,6 +6,7 @@
using System.Linq;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Text;
using Roslyn.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
......@@ -185,7 +186,32 @@ public AbstractTableEntriesSnapshot<TData> CreateSnapshot(int version, Immutable
return _tableSource.CreateSnapshot(_sources.Primary, version, items, trackingPoints);
}
return _tableSource.CreateSnapshot(_sources.GetSources().First(), version, items, trackingPoints);
// we can be called back from error list while all sources are removed but before error list know about it yet
// since notification is pending in the queue.
var source = _sources.GetSources().FirstOrDefault();
if (source == null)
{
return new EmptySnapshot(version);
}
return _tableSource.CreateSnapshot(source, version, items, trackingPoints);
}
private class EmptySnapshot : AbstractTableEntriesSnapshot<TData>
{
public EmptySnapshot(int version) :
base(version, ImmutableArray<TableItem<TData>>.Empty, ImmutableArray<ITrackingPoint>.Empty)
{
}
protected override bool IsEquivalent(TData item1, TData item2) => false;
public override bool TryNavigateTo(int index, bool previewTab) => false;
public override bool TryGetValue(int index, string columnName, out object content)
{
content = null;
return false;
}
}
private class EntriesSourceCollections
......@@ -195,6 +221,7 @@ private class EntriesSourceCollections
public EntriesSourceCollections(AbstractTableEntriesSource<TData> primary)
{
Contract.ThrowIfNull(primary);
_primary = primary;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册