コード エディターで拡張機能からコードを追加/削除するにはどうすればよいですか?
例:
拡張ウィッチを作成し、着信ソケットからコードを変更します
。この例では、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() 関数が失敗するため、別の方法があると思います