提交 c145e41d 编写于 作者: S Sam Harwell

Avoid leaking documents if an exception is thrown in AddDocument

Fixes #22723
上级 a4239cbc
......@@ -1027,7 +1027,13 @@ internal void AddDocument(IVisualStudioHostDocument document, bool isCurrentCont
{
lock (_gate)
{
_documents.Add(document.Id, document);
// This condition ensures that if we throw an exception for either Add operation, the document will
// not be added to either collection.
if (!_documentMonikers.ContainsKey(document.Key.Moniker))
{
_documents.Add(document.Id, document);
}
_documentMonikers.Add(document.Key.Moniker, document);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册