未验证 提交 a87c1bdf 编写于 作者: J Jason Malinowski 提交者: GitHub

Merge pull request #46491 from jasonmalinowski/delete-unnecessary-code-from-invisibleeditor

Delete a workaround from InvisibleEditor.cs
......@@ -48,7 +48,7 @@ public InvisibleEditor(IServiceProvider serviceProvider, string filePath, IVsHie
_needsSave = needsSave;
var invisibleEditorManager = (IIntPtrReturningVsInvisibleEditorManager)serviceProvider.GetService(typeof(SVsInvisibleEditorManager));
var vsProject = TryGetProjectOfHierarchy(hierarchy);
var vsProject = hierarchy as IVsProject;
Marshal.ThrowExceptionForHR(invisibleEditorManager.RegisterInvisibleEditor(filePath, vsProject, 0, null, out var invisibleEditorPtr));
try
......@@ -88,34 +88,6 @@ public InvisibleEditor(IServiceProvider serviceProvider, string filePath, IVsHie
}
}
private IVsProject? TryGetProjectOfHierarchy(IVsHierarchy? hierarchy)
{
// The invisible editor manager will fail in cases where the IVsProject passed to it is not consistent with
// the IVsProject known to IVsSolution (e.g. if the object is a wrapper like AbstractHostObject created by
// the CPS-based project system). This method returns an IVsProject instance known to the solution, or null
// if the project could not be determined.
if (hierarchy == null)
{
return null;
}
if (!ErrorHandler.Succeeded(hierarchy.GetGuidProperty(
(uint)VSConstants.VSITEMID.Root,
(int)__VSHPROPID.VSHPROPID_ProjectIDGuid,
out var projectId)))
{
return null;
}
var solution = (IVsSolution)_serviceProvider.GetService(typeof(SVsSolution));
if (!ErrorHandler.Succeeded(solution.GetProjectOfGuid(projectId, out var projectHierarchy)))
{
return null;
}
return projectHierarchy as IVsProject;
}
public IVsTextLines VsTextLines
{
get
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册