【发布时间】:2013-10-01 08:45:45
【问题描述】:
我使用 ITextParagraphPropertiesFactoryService 类创建了一个扩展,以自定义方式格式化与编辑器选项卡。一切正常,期待这样一个事实,当用户输入新行时,ITextParagraphPropertiesFactoryService 不会影响新行
为了简化问题,我新建了一个MEF项目,像这样添加格式提供者
[Export(typeof(ITextParagraphPropertiesFactoryService))]
[ContentType("text")]
[TextViewRole(PredefinedTextViewRoles.Document)]
internal class ElasticTabstopsProvider : ITextParagraphPropertiesFactoryService
{
/// <summary>
/// Creates an ElasticTabstopsFormatters for
/// the provided configuration.
/// </summary>
public TextParagraphProperties Create(IFormattedLineSource formattedLineSource, TextFormattingRunProperties textProperties,
IMappingSpan line, IMappingPoint lineStart, int lineSegment)
{
return new TextFormattingParagraphProperties(textProperties, 1);
}
}
它会将我的编辑器中的所有选项卡宽度更改为 1。太棒了!这就是我要的。但是现在当我按下 Enter(new line) 时,新光标设置在 Main 下,但是我希望选项卡宽度为 1。
在我开始输入后,它会转到预期的位置。
问题是,如何设置新行空行制表符大小?
我尝试覆盖ISmartIndentProvider,但似乎忽略了该值。
调试器在方法中的断点处停止
int? GetDesiredIndentation(ITextSnapshotLine currentLine)
ISmartIndent,但无论我返回什么值,缩进都保持不变...
【问题讨论】: