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); }