如何在代码编辑器中从扩展中添加/删除代码?将代码添加到Visual Studio包中的当前编辑器窗口/延伸
例如:
我创建的扩展女巫从进入的插座
该示例使用Microsoft.VisualStudio.Text.Editor
尝试使用修改的代码:
IWpfTextView textView; // got from visual studio "Create" event ITextChange change; // Got from network socket or other source
ITextEdit edit = textView.TextBuffer.CreateEdit(); // Throws "Not Owner" Exception edit.Delete(change.OldSpan); edit.Insert(change.NewPosition, change.NewText);
但我猜还有另一种方式,因为CrateEdit()函数失败
您可以发布完整的错误消息? – JaredPar 2010-12-01 16:59:55
错误:试图在错误的线程上编辑TextBuffer。 和“textView.TextBuffer.TakeThreadOwnership();”引发: 试图更改TextBuffer的编辑线程。 – 2010-12-01 17:35:03