public VsCommandTargetTest() { _textView = CreateTextView(""); _buffer = Vim.CreateVimBuffer(_textView); _bufferCoordinator = new VimBufferCoordinator(_buffer); _vim = _buffer.Vim; _factory = new MockRepository(MockBehavior.Strict); // By default Resharper isn't loaded _resharperUtil = _factory.Create<IResharperUtil>(); _resharperUtil.SetupGet(x => x.IsInstalled).Returns(false); _nextTarget = _factory.Create<IOleCommandTarget>(MockBehavior.Strict); _vsAdapter = _factory.Create<IVsAdapter>(); _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(InputManager.Current.PrimaryKeyboardDevice); _vsAdapter.Setup(x => x.InAutomationFunction).Returns(false); _vsAdapter.Setup(x => x.InDebugMode).Returns(false); _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false); _broker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Loose); var oldCommandFilter = _nextTarget.Object; var vsTextView = _factory.Create<IVsTextView>(MockBehavior.Loose); vsTextView.Setup(x => x.AddCommandFilter(It.IsAny<IOleCommandTarget>(), out oldCommandFilter)).Returns(0); var result = VsCommandTarget.Create( _bufferCoordinator, vsTextView.Object, _vsAdapter.Object, _broker.Object, _resharperUtil.Object, KeyUtil); Assert.True(result.IsSuccess); _targetRaw = result.Value; _target = _targetRaw; }
public void SetUp() { var textView = EditorUtil.CreateView(""); _buffer = EditorUtil.FactoryService.Vim.CreateBuffer(textView); _factory = new MockRepository(MockBehavior.Strict); // By default resharper isn't loaded _externalEditorManager = _factory.Create <IExternalEditorManager>(); _externalEditorManager.SetupGet(x => x.IsResharperLoaded).Returns(false); _nextTarget = _factory.Create <IOleCommandTarget>(MockBehavior.Loose); _adapter = _factory.Create <IVsAdapter>(); _adapter.Setup(x => x.InAutomationFunction).Returns(false); _adapter.Setup(x => x.InDebugMode).Returns(false); _adapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny <ITextView>())).Returns(false); _broker = _factory.Create <IDisplayWindowBroker>(MockBehavior.Loose); var oldCommandFilter = _nextTarget.Object; var vsTextView = _factory.Create <IVsTextView>(MockBehavior.Loose); vsTextView.Setup(x => x.AddCommandFilter(It.IsAny <IOleCommandTarget>(), out oldCommandFilter)).Returns(0); var result = VsCommandTarget.Create( _buffer, vsTextView.Object, _adapter.Object, _broker.Object, _externalEditorManager.Object); Assert.IsTrue(result.IsSuccess); _targetRaw = result.Value; _target = _targetRaw; }
protected VsCommandTargetTest(bool isReSharperInstalled) { _textView = CreateTextView(""); _textBuffer = _textView.TextBuffer; _vimBuffer = Vim.CreateVimBuffer(_textView); _bufferCoordinator = new VimBufferCoordinator(_vimBuffer); _vim = _vimBuffer.Vim; _factory = new MockRepository(MockBehavior.Strict); _nextTarget = _factory.Create <IOleCommandTarget>(MockBehavior.Strict); _vsAdapter = _factory.Create <IVsAdapter>(); _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(InputManager.Current.PrimaryKeyboardDevice); _vsAdapter.Setup(x => x.InAutomationFunction).Returns(false); _vsAdapter.Setup(x => x.InDebugMode).Returns(false); _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny <ITextView>())).Returns(false); _broker = _factory.Create <IDisplayWindowBroker>(MockBehavior.Loose); _textManager = _factory.Create <ITextManager>(); _commonOperations = _factory.Create <ICommonOperations>(); _vimApplicationSettings = _factory.Create <IVimApplicationSettings>(); var commandTargets = new List <ICommandTarget>(); if (isReSharperInstalled) { commandTargets.Add(ReSharperKeyUtil.GetOrCreate(_bufferCoordinator)); } commandTargets.Add(new StandardCommandTarget( _bufferCoordinator, _textManager.Object, _commonOperations.Object, _broker.Object, _nextTarget.Object)); var oldCommandFilter = _nextTarget.Object; _targetRaw = new VsCommandTarget( _bufferCoordinator, _textManager.Object, _vsAdapter.Object, _broker.Object, KeyUtil, _vimApplicationSettings.Object, _nextTarget.Object, commandTargets.ToReadOnlyCollectionShallow()); _target = _targetRaw; }
protected VsCommandTargetTest() { _textView = CreateTextView(""); _textBuffer = _textView.TextBuffer; _vimBuffer = Vim.CreateVimBuffer(_textView); _bufferCoordinator = new VimBufferCoordinator(_vimBuffer); _vim = _vimBuffer.Vim; _factory = new MockRepository(MockBehavior.Strict); // By default Resharper isn't loaded _resharperUtil = _factory.Create <IReSharperUtil>(); _resharperUtil.SetupGet(x => x.IsInstalled).Returns(false); _nextTarget = _factory.Create <IOleCommandTarget>(MockBehavior.Strict); _vsAdapter = _factory.Create <IVsAdapter>(); _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(InputManager.Current.PrimaryKeyboardDevice); _vsAdapter.Setup(x => x.InAutomationFunction).Returns(false); _vsAdapter.Setup(x => x.InDebugMode).Returns(false); _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny <ITextView>())).Returns(false); _broker = _factory.Create <IDisplayWindowBroker>(MockBehavior.Loose); _textManager = _factory.Create <ITextManager>(); var oldCommandFilter = _nextTarget.Object; var vsTextView = _factory.Create <IVsTextView>(MockBehavior.Loose); vsTextView.Setup(x => x.AddCommandFilter(It.IsAny <IOleCommandTarget>(), out oldCommandFilter)).Returns(0); var result = VsCommandTarget.Create( _bufferCoordinator, vsTextView.Object, _textManager.Object, _vsAdapter.Object, _broker.Object, _resharperUtil.Object, KeyUtil); Assert.True(result.IsSuccess); _targetRaw = result.Value; _target = _targetRaw; }
protected VsCommandTargetTest(bool isReSharperInstalled) { _textView = CreateTextView(""); _textBuffer = _textView.TextBuffer; _vimBuffer = Vim.CreateVimBuffer(_textView); _bufferCoordinator = new VimBufferCoordinator(_vimBuffer); _vim = _vimBuffer.Vim; _factory = new MockRepository(MockBehavior.Strict); _nextTarget = _factory.Create<IOleCommandTarget>(MockBehavior.Strict); _vsAdapter = _factory.Create<IVsAdapter>(); _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(InputManager.Current.PrimaryKeyboardDevice); _vsAdapter.Setup(x => x.InAutomationFunction).Returns(false); _vsAdapter.Setup(x => x.InDebugMode).Returns(false); _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false); _broker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Loose); _textManager = _factory.Create<ITextManager>(); _vimApplicationSettings = _factory.Create<IVimApplicationSettings>(); var commandTargets = new List<ICommandTarget>(); if (isReSharperInstalled) { commandTargets.Add(ReSharperKeyUtil.GetOrCreate(_bufferCoordinator)); } commandTargets.Add(new StandardCommandTarget(_bufferCoordinator, _textManager.Object, _broker.Object, _nextTarget.Object)); var oldCommandFilter = _nextTarget.Object; _targetRaw = new VsCommandTarget( _bufferCoordinator, _textManager.Object, _vsAdapter.Object, _broker.Object, KeyUtil, _vimApplicationSettings.Object, _nextTarget.Object, commandTargets.ToReadOnlyCollectionShallow()); _target = _targetRaw; }
internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper) { _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView; _factory = new MockRepository(MockBehavior.Strict); // Create the IVsAdapter and pick reasonable defaults here. Consumers can modify // this via an exposed property _vsAdapter = _factory.Create <IVsAdapter>(); _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false); _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextBuffer>())).Returns(false); _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false); _externalEditorManager = _factory.Create <IExternalEditorManager>(); _externalEditorManager.SetupGet(x => x.IsResharperInstalled).Returns(simulateResharper); _displayWindowBroker = _factory.Create <IDisplayWindowBroker>(); _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false); _defaultCommandTarget = new DefaultCommandTarget( bufferCoordinator.VimBuffer.TextView, EditorUtil.GetEditorOperations(bufferCoordinator.VimBuffer.TextView)); // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property // bag. The default KeyProcessor implementation looks here for IOleCommandTarget to // process text input _wpfTextView.Properties[typeof(IOleCommandTarget)] = _defaultCommandTarget; // Create the VsCommandTarget. It's next is the final and default Visual Studio // command target var vsTextView = _factory.Create <IVsTextView>(); IOleCommandTarget nextCommandTarget = _defaultCommandTarget; vsTextView.Setup(x => x.AddCommandFilter(It.IsAny <IOleCommandTarget>(), out nextCommandTarget)).Returns(VSConstants.S_OK); var vsCommandTarget = VsCommandTarget.Create( bufferCoordinator, vsTextView.Object, _vsAdapter.Object, _displayWindowBroker.Object, _externalEditorManager.Object).Value; // Time to setup the start command target. If we are simulating R# then put them ahead of VsVim // on the IOleCommandTarget chain. VsVim doesn't try to fight R# and prefers instead to be // behind them if (simulateResharper) { var resharperCommandTarget = new ResharperCommandTarget(_wpfTextView, vsCommandTarget); _commandTarget = resharperCommandTarget; } else { _commandTarget = vsCommandTarget; } // Create the input controller. Make sure that the VsVim one is ahead in the list // from the default Visual Studio one. We can guarantee this is true due to MEF // ordering of the components var keyProcessors = new List <Microsoft.VisualStudio.Text.Editor.KeyProcessor>(); keyProcessors.Add(new VsKeyProcessor(_vsAdapter.Object, bufferCoordinator)); keyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView)); _defaultInputController = new DefaultInputController(bufferCoordinator.VimBuffer.TextView, keyProcessors); _defaultKeyboardDevice = new DefaultKeyboardDevice(InputManager.Current); }
public void SetUp() { var textView = EditorUtil.CreateView(""); _buffer = EditorUtil.FactoryService.Vim.CreateBuffer(textView); _factory = new MockRepository(MockBehavior.Strict); // By default resharper isn't loaded _externalEditorManager = _factory.Create<IExternalEditorManager>(); _externalEditorManager.SetupGet(x => x.IsResharperLoaded).Returns(false); _nextTarget = _factory.Create<IOleCommandTarget>(MockBehavior.Loose); _adapter = _factory.Create<IVsAdapter>(); _adapter.Setup(x => x.InAutomationFunction).Returns(false); _adapter.Setup(x => x.InDebugMode).Returns(false); _adapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false); _broker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Loose); var oldCommandFilter = _nextTarget.Object; var vsTextView = _factory.Create<IVsTextView>(MockBehavior.Loose); vsTextView.Setup(x => x.AddCommandFilter(It.IsAny<IOleCommandTarget>(), out oldCommandFilter)).Returns(0); var result = VsCommandTarget.Create( _buffer, vsTextView.Object, _adapter.Object, _broker.Object, _externalEditorManager.Object); Assert.IsTrue(result.IsSuccess); _targetRaw = result.Value; _target = _targetRaw; }
internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper, bool simulateStandardKeyMappings, IEditorOperationsFactoryService editorOperationsFactoryService, IKeyUtil keyUtil) { _keyUtil = keyUtil; _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView; _factory = new MockRepository(MockBehavior.Strict); _vsKeyboardInputSimulation = new VsKeyboardInputSimulation(this, _wpfTextView); _simulateStandardKeyMappings = simulateStandardKeyMappings; // Create the IVsAdapter and pick reasonable defaults here. Consumers can modify // this via an exposed property _vsAdapter = _factory.Create <IVsAdapter>(); _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false); _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(_vsKeyboardInputSimulation.KeyBoardDevice); _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextBuffer>())).Returns(false); _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextView>())).Returns(false); _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false); _reportDesignerUtil = _factory.Create <IReportDesignerUtil>(); _reportDesignerUtil.Setup(x => x.IsExpressionView(_wpfTextView)).Returns(false); _displayWindowBroker = _factory.Create <IDisplayWindowBroker>(); _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false); _vimApplicationSettings = _factory.Create <IVimApplicationSettings>(); _vimApplicationSettings.SetupGet(x => x.UseEditorDefaults).Returns(true); _vimApplicationSettings.SetupGet(x => x.UseEditorIndent).Returns(true); _vimApplicationSettings.SetupGet(x => x.UseEditorTabAndBackspace).Returns(true); _commonOperations = _factory.Create <ICommonOperations>(); _vsSimulationCommandTarget = new SimulationCommandTarget( bufferCoordinator.VimBuffer.TextView, editorOperationsFactoryService.GetEditorOperations(bufferCoordinator.VimBuffer.TextView)); var textManager = _factory.Create <ITextManager>(); var commandTargets = new List <ICommandTarget>(); if (simulateResharper) { commandTargets.Add(ReSharperKeyUtil.GetOrCreate(bufferCoordinator)); } commandTargets.Add(new StandardCommandTarget( bufferCoordinator, textManager.Object, _commonOperations.Object, _displayWindowBroker.Object, _vsSimulationCommandTarget)); // Create the VsCommandTarget. It's next is the final and default Visual Studio // command target _vsCommandTarget = new VsCommandTarget( bufferCoordinator, textManager.Object, _vsAdapter.Object, _displayWindowBroker.Object, _keyUtil, _vimApplicationSettings.Object, _vsSimulationCommandTarget, commandTargets.ToReadOnlyCollectionShallow()); // Time to setup the start command target. If we are simulating R# then put them ahead of VsVim // on the IOleCommandTarget chain. VsVim doesn't try to fight R# and prefers instead to be // behind them if (simulateResharper) { _reSharperCommandTarget = new ReSharperCommandTargetSimulation(_wpfTextView, _vsCommandTarget); _commandTarget = _reSharperCommandTarget; } else { _commandTarget = _vsCommandTarget; } // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property // bag. The default KeyProcessor implementation looks here for IOleCommandTarget to // process text input. // // This should always point to the head of the IOleCommandTarget chain. In the implementation // it actually points to the IVsTextView implementation which then immediately routes to the // IOleCommandTarget head _wpfTextView.Properties[typeof(IOleCommandTarget)] = _commandTarget; // Create the input controller. Make sure that the VsVim one is ahead in the list // from the default Visual Studio one. We can guarantee this is true due to MEF // ordering of the components if (simulateResharper) { _vsKeyboardInputSimulation.KeyProcessors.Add(ReSharperKeyUtil.GetOrCreate(bufferCoordinator)); } _vsKeyboardInputSimulation.KeyProcessors.Add(new VsVimKeyProcessor(_vsAdapter.Object, bufferCoordinator, _keyUtil, _reportDesignerUtil.Object)); _vsKeyboardInputSimulation.KeyProcessors.Add((KeyProcessor)bufferCoordinator); _vsKeyboardInputSimulation.KeyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView)); }
internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper, bool simulateStandardKeyMappings, IEditorOperationsFactoryService editorOperationsFactoryService, IKeyUtil keyUtil) { _keyUtil = keyUtil; _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView; _factory = new MockRepository(MockBehavior.Strict); _vsKeyboardInputSimulation = new VsKeyboardInputSimulation(this, _wpfTextView); _testableSynchronizationContext = new TestableSynchronizationContext(); _simulateStandardKeyMappings = simulateStandardKeyMappings; // Create the IVsAdapter and pick reasonable defaults here. Consumers can modify // this via an exposed property _vsAdapter = _factory.Create<IVsAdapter>(); _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false); _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(_vsKeyboardInputSimulation.KeyBoardDevice); _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny<ITextBuffer>())).Returns(false); _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny<ITextView>())).Returns(false); _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false); _reportDesignerUtil = _factory.Create<IReportDesignerUtil>(); _reportDesignerUtil.Setup(x => x.IsExpressionView(_wpfTextView)).Returns(false); _displayWindowBroker = _factory.Create<IDisplayWindowBroker>(); _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false); _vimApplicationSettings = _factory.Create<IVimApplicationSettings>(); _vimApplicationSettings.SetupGet(x => x.UseEditorDefaults).Returns(true); _vimApplicationSettings.SetupGet(x => x.UseEditorIndent).Returns(true); _vimApplicationSettings.SetupGet(x => x.UseEditorTabAndBackspace).Returns(true); _vsSimulationCommandTarget = new SimulationCommandTarget( bufferCoordinator.VimBuffer.TextView, editorOperationsFactoryService.GetEditorOperations(bufferCoordinator.VimBuffer.TextView)); var textManager = _factory.Create<ITextManager>(); var commandTargets = new List<ICommandTarget>(); if (simulateResharper) { commandTargets.Add(ReSharperKeyUtil.GetOrCreate(bufferCoordinator)); } commandTargets.Add(new StandardCommandTarget(bufferCoordinator, textManager.Object, _displayWindowBroker.Object, _vsSimulationCommandTarget)); // Create the VsCommandTarget. It's next is the final and default Visual Studio // command target _vsCommandTarget = new VsCommandTarget( bufferCoordinator, textManager.Object, _vsAdapter.Object, _displayWindowBroker.Object, _keyUtil, _vimApplicationSettings.Object, _vsSimulationCommandTarget, commandTargets.ToReadOnlyCollectionShallow()); // Time to setup the start command target. If we are simulating R# then put them ahead of VsVim // on the IOleCommandTarget chain. VsVim doesn't try to fight R# and prefers instead to be // behind them if (simulateResharper) { _reSharperCommandTarget = new ReSharperCommandTargetSimulation(_wpfTextView, _vsCommandTarget); _commandTarget = _reSharperCommandTarget; } else { _commandTarget = _vsCommandTarget; } // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property // bag. The default KeyProcessor implementation looks here for IOleCommandTarget to // process text input. // // This should always point to the head of the IOleCommandTarget chain. In the implementation // it actually points to the IVsTextView implementation which then immediately routes to the // IOleCommandTarget head _wpfTextView.Properties[typeof(IOleCommandTarget)] = _commandTarget; // Create the input controller. Make sure that the VsVim one is ahead in the list // from the default Visual Studio one. We can guarantee this is true due to MEF // ordering of the components if (simulateResharper) { _vsKeyboardInputSimulation.KeyProcessors.Add(ReSharperKeyUtil.GetOrCreate(bufferCoordinator)); } _vsKeyboardInputSimulation.KeyProcessors.Add(new VsVimKeyProcessor(_vsAdapter.Object, bufferCoordinator, _keyUtil, _reportDesignerUtil.Object)); _vsKeyboardInputSimulation.KeyProcessors.Add((KeyProcessor)bufferCoordinator); _vsKeyboardInputSimulation.KeyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView)); }
internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper, bool simulateStandardKeyMappings, IEditorOperationsFactoryService editorOperationsFactoryService, IKeyUtil keyUtil) { _keyUtil = keyUtil; _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView; _factory = new MockRepository(MockBehavior.Strict); _vsKeyProcessorSimulation = new VsKeyProcessorSimulation(this, _wpfTextView); _testableSynchronizationContext = new TestableSynchronizationContext(); _simulateStandardKeyMappings = simulateStandardKeyMappings; // Create the IVsAdapter and pick reasonable defaults here. Consumers can modify // this via an exposed property _vsAdapter = _factory.Create <IVsAdapter>(); _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false); _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(_vsKeyProcessorSimulation.KeyBoardDevice); _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextBuffer>())).Returns(false); _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextView>())).Returns(false); _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false); _resharperUtil = _factory.Create <IResharperUtil>(); _resharperUtil.SetupGet(x => x.IsInstalled).Returns(simulateResharper); _displayWindowBroker = _factory.Create <IDisplayWindowBroker>(); _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false); _defaultCommandTarget = new DefaultCommandTarget( bufferCoordinator.VimBuffer.TextView, editorOperationsFactoryService.GetEditorOperations(bufferCoordinator.VimBuffer.TextView)); // Create the VsCommandTarget. It's next is the final and default Visual Studio // command target var vsTextView = _factory.Create <IVsTextView>(); IOleCommandTarget nextCommandTarget = _defaultCommandTarget; vsTextView.Setup(x => x.AddCommandFilter(It.IsAny <IOleCommandTarget>(), out nextCommandTarget)).Returns(VSConstants.S_OK); var vsCommandTarget = VsCommandTarget.Create( bufferCoordinator, vsTextView.Object, _factory.Create <ITextManager>().Object, _vsAdapter.Object, _displayWindowBroker.Object, _resharperUtil.Object, _keyUtil).Value; // Time to setup the start command target. If we are simulating R# then put them ahead of VsVim // on the IOleCommandTarget chain. VsVim doesn't try to fight R# and prefers instead to be // behind them if (simulateResharper) { var resharperCommandTarget = new ResharperCommandTarget(_wpfTextView, vsCommandTarget); _commandTarget = resharperCommandTarget; } else { _commandTarget = vsCommandTarget; } // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property // bag. The default KeyProcessor implementation looks here for IOleCommandTarget to // process text input. // // This should always point to the head of the IOleCommandTarget chain. In the implementation // it actually points to the IVsTextView implementation which then immediately routes to the // IOleCommandTarget head _wpfTextView.Properties[typeof(IOleCommandTarget)] = _commandTarget; // Create the input controller. Make sure that the VsVim one is ahead in the list // from the default Visual Studio one. We can guarantee this is true due to MEF // ordering of the components _vsKeyProcessorSimulation.KeyProcessors.Add(new VsKeyProcessor(_vsAdapter.Object, bufferCoordinator, _keyUtil)); _vsKeyProcessorSimulation.KeyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView)); }