提交 3a1a3b14 编写于 作者: D David Barbet

Don't attempt to provide a navbar if there is no navbar language service.

上级 3918f04f
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license 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;
......@@ -62,6 +65,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.
先完成此消息的编辑!
想要评论请 注册