private IVsTextLines EnsureBufferCoordinator() { if (_secondaryBuffer != null) { return(_secondaryBuffer); } var vsTextBuffer = owner.Document.TextBuffer.QueryInterface <IVsTextBuffer>(); IVsEditorAdaptersFactoryService adapterFactory = WebEditor.ExportProvider.GetExport <IVsEditorAdaptersFactoryService>().Value; _secondaryBuffer = (adapterFactory.GetBufferAdapter(ProjectionBuffer.IProjectionBuffer) as IVsTextLines); if (_secondaryBuffer == null) { _secondaryBuffer = (adapterFactory.CreateVsTextBufferAdapterForSecondaryBuffer(vsTextBuffer.GetServiceProvider(), ProjectionBuffer.IProjectionBuffer) as IVsTextLines); } _secondaryBuffer.SetTextBufferData(VSConstants.VsTextBufferUserDataGuid.VsBufferDetectLangSID_guid, false); _secondaryBuffer.SetTextBufferData(VSConstants.VsTextBufferUserDataGuid.VsBufferMoniker_guid, owner.WorkspaceItem.PhysicalPath); IOleUndoManager oleUndoManager; _secondaryBuffer.GetUndoManager(out oleUndoManager); oleUndoManager.Enable(0); _textBufferCoordinator = adapterFactory.CreateVsTextBufferCoordinatorAdapter(); vsTextBuffer.SetTextBufferData(HtmlConstants.SID_SBufferCoordinatorServerLanguage, _textBufferCoordinator); vsTextBuffer.SetTextBufferData(typeof(VsTextBufferCoordinatorClass).GUID, _textBufferCoordinator); _textBufferCoordinator.SetBuffers(vsTextBuffer as IVsTextLines, _secondaryBuffer); return(_secondaryBuffer); }
IWpfTextView IInteractiveWindowEditorFactoryService.CreateTextView(IInteractiveWindow window, ITextBuffer buffer, ITextViewRoleSet roles) { var bufferAdapter = _adapterFactory.CreateVsTextBufferAdapterForSecondaryBuffer(_provider, buffer); // Create and initialize text view adapter. // WARNING: This might trigger various services like IntelliSense, margins, taggers, etc. var textViewAdapter = _adapterFactory.CreateVsTextViewAdapter(_provider, roles); var commandFilter = new VsInteractiveWindowCommandFilter(_adapterFactory, window, textViewAdapter, bufferAdapter); window.Properties[typeof(VsInteractiveWindowCommandFilter)] = commandFilter; return(commandFilter.TextViewHost.TextView); }