Пользовательский редактор Visual Studio должен реагировать на ввод ключа

Я работаю над проектом, в котором мне нужно создать собственные редакторы и использовать проекционные буферы для пользовательских файлов кода. Мне удалось создать окно кода, выполнив шаги, описанные в этой статье https://joshvarty.wordpress.com/ 2014/08/01 / копирования-на-визуальной-студия-редактор, кроме-с проекционными-буферами /

кодовое изображение окна

Тем не менее, я не могу заставить окно кода реагировать на любые ключевые вводы, хотя перетаскивание работает

Расширение написано для visual studio 2015, есть ли какие-то дополнительные шаги, которые нужно предпринять, чтобы окно кода работало?

Это код, который я использую:

 public IWpfTextViewHost CreateEditor(string filePath, int start = 0, int end = 0, bool createProjectedEditor = false)
    {
        //IVsInvisibleEditors are in-memory represenations of typical Visual Studio editors.
        //Language services, highlighting and error squiggles are hooked up to these editors
        //for us once we convert them to WpfTextViews. 
        var invisibleEditor = GetInvisibleEditor(filePath);

        var docDataPointer = IntPtr.Zero;
        Guid guidIVsTextLines = typeof(IVsTextLines).GUID;

        ErrorHandler.ThrowOnFailure(invisibleEditor.GetDocData(
            fEnsureWritable: 1
            , riid: ref guidIVsTextLines
            , ppDocData: out docDataPointer));

        IVsTextLines docData = (IVsTextLines)Marshal.GetObjectForIUnknown(docDataPointer);

        //Create a code window adapter
        var codeWindow = _editorAdapter.CreateVsCodeWindowAdapter(VisualStudioServices.OLEServiceProvider);
        ErrorHandler.ThrowOnFailure(codeWindow.SetBuffer(docData));

        //Get a text view for our editor which we will then use to get the WPF control for that editor.
        IVsTextView textView;
        ErrorHandler.ThrowOnFailure(codeWindow.GetPrimaryView(out textView));

        _currentlyFocusedTextView = textView;


        RegisterDocument(filePath);


        var textViewHost = _editorAdapter.GetWpfTextViewHost(textView);

        return textViewHost;
    }

0 ответов

Другие вопросы по тегам