未验证 提交 5fb71c0a 编写于 作者: D David 提交者: GitHub

Merge pull request #41010 from dibarbet/fix_navbar

Don't attempt to provide a navbar if there is no navbar language serv…
......@@ -3,9 +3,12 @@
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
using System.Linq;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.Options;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServices.Implementation.NavigationBar;
using Microsoft.VisualStudio.TextManager.Interop;
using Roslyn.Utilities;
......@@ -64,6 +67,19 @@ private void AddOrRemoveDropdown(bool enabled)
return;
}
if (ErrorHandler.Failed(_codeWindow.GetBuffer(out var buffer)))
{
return;
}
// Temporary solution until the editor provides a proper way to resolve the correct navbar.
// Tracked in https://github.com/dotnet/roslyn/issues/40989
var document = _languageService.EditorAdaptersFactoryService.GetDataBuffer(buffer).AsTextContainer().GetRelatedDocuments().FirstOrDefault();
if (document.GetLanguageService<INavigationBarItemService>() == null)
{
return;
}
if (enabled)
{
var existingDropdownBar = GetDropdownBar(dropdownManager);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册