public void SetUp()
 {
     _buffer = new Mock<IVimBuffer>();
     _textView = new Mock<IVsTextView>();
     _vsExt = new Mock<IVsExtensibility>(MockBehavior.Strict);
     _vsExt.Setup(x => x.IsInAutomationFunction()).Returns(0);
     _serviceProvider = MockObjectFactory.CreateServiceProvider(Tuple.Create(typeof(IVsExtensibility), (object)_vsExt.Object));
     _filter = new VsCommandFilter(_buffer.Object, _textView.Object, _serviceProvider.Object);
 }
Exemple #2
0
        void IVsTextViewCreationListener.VsTextViewCreated(IVsTextView vsView)
        {
            var view = _adaptersFactory.GetWpfTextView(vsView);
            if (view == null)
            {
                return;
            }

            var opt = _vim.GetBuffer(view);
            if (!opt.IsSome())
            {
                return;
            }

            var buffer = opt.Value;
            var filter = new VsCommandFilter(buffer, vsView, _serviceProvider);
            _filterMap.Add(buffer, filter);

            // Try and install the IVsFilterKeys adapter.  This cannot be done synchronously here
            // because Venus projects are not fully initialized at this state.  Merely querying
            // for properties cause them to corrupt internal state and prevents rendering of the
            // view.  Occurs for aspx and .js pages
            Action install = () =>
                {
                    VsFilterKeysAdapter.TryInstallFilterKeysAdapter(_adapter, _editorOptionsFactoryService, buffer);
                };

            Dispatcher.CurrentDispatcher.BeginInvoke(install, null);
        }
Exemple #3
0
        private void OnGotAggregateFocus(object sender, EventArgs e)
        {
            var view = sender as IWpfTextView;
            if (view == null)
            {
                return;
            }

            var vsView = _adaptersFactory.GetViewAdapter(view);
            if (vsView == null)
            {
                return;
            }

            // Once we have the Vs view, stop listening to the event
            view.GotAggregateFocus -= new EventHandler(OnGotAggregateFocus);
            var opt = _vim.GetBuffer(view);
            if (!opt.IsSome())
            {
                return;
            }

            var buffer = opt.Value;
            var filter = new VsCommandFilter(buffer, vsView);
            _filterMap.Add(buffer, filter);
        }
Exemple #4
0
        void IVsTextViewCreationListener.VsTextViewCreated(IVsTextView vsView)
        {
            // Once we have the Vs view, stop listening to the event
            var view = _adaptersFactory.GetWpfTextView(vsView);
            if (view == null)
            {
                return;
            }

            var opt = _vim.GetBuffer(view);
            if (!opt.IsSome())
            {
                return;
            }

            var buffer = opt.Value;
            var filter = new VsCommandFilter(buffer, vsView, _serviceProvider);
            _filterMap.Add(buffer, filter);
        }