如何在 visual studio 编辑器 window 上隐藏或显示自定义边距

How can I hide or show a custom margin on a visual studio editor window

在 VSIX 项目中,我可以使用 编辑器边距 项模板为编辑器定义自定义边距。

有什么方法可以隐藏或显示我的 Visual Studio 扩展程序的自定义边距?

或者,我的扩展是否可以打开一个新的编辑器 window 带有自定义边距,默认情况下是不可见的?

对于我的应用程序,我能够在保证金工厂中处理它,它决定是否创建保证金。 如果它不创建边距,它只是 return null。

在保证金工厂中,我导入了 TextDocumentFactoryService

[Import]
public ITextDocumentFactoryService TextDocumentFactoryService { get; set; }

并使用它在编辑器中获取文件名

ITextDocument document;
var isok = TextDocumentFactoryService.TryGetTextDocument(wpfTextViewHost.TextView.TextDataModel.DocumentBuffer, out document ) ;
var fn   = document.FilePath ;

我也定义了一个自己的MEF服务,同样导入保证金工厂。我使用这项服务

  • 判断是否需要保证金
  • 获取我需要在页边显示的信息

这个用于实现AnkhSVN2019中的标注功能。相关文件在 this directory 中。