int IVsCodeWindowEvents.OnNewView(IVsTextView vsTextView) { var wpfTextView = VsEditorAdaptersFactoryService.GetWpfTextView(vsTextView); if (wpfTextView != null) { var factory = ComponentModel.GetService<IEditorOperationsFactoryService>(); var editFilter = new EditFilter(wpfTextView, factory.GetEditorOperations(wpfTextView), ServiceProvider.GlobalProvider); editFilter.AttachKeyboardFilter(vsTextView); wpfTextView.GotAggregateFocus += OnTextViewGotAggregateFocus; wpfTextView.LostAggregateFocus += OnTextViewLostAggregateFocus; } return VSConstants.S_OK; }