internal AbstractOleCommandTarget AttachToVsTextView() { var vsTextView = EditorAdaptersFactory.GetViewAdapter(WpfTextView); // Add command filter to IVsTextView. If something goes wrong, throw. var returnValue = vsTextView.AddCommandFilter(this, out var nextCommandTarget); Marshal.ThrowExceptionForHR(returnValue); Contract.ThrowIfNull(nextCommandTarget); NextCommandTarget = nextCommandTarget; return(this); }
public void TextViewCreated(IWpfTextView textView) { CommandFilter filter = new CommandFilter(textView, SmartIndentation); IVsTextView view = EditorAdaptersFactory.GetViewAdapter(textView); if (view != null) { IOleCommandTarget next = null; int result = view.AddCommandFilter(filter, out next); if (result == VSConstants.S_OK) { filter.Next = next; } } }