KeyProcessor IKeyProcessorProvider.GetAssociatedProcessor(IWpfTextView wpfTextView) { var buffer = _vim.GetOrCreateVimBuffer(wpfTextView); var bufferCoordinator = _bufferCoordinatorFactory.GetVimBufferCoordinator(buffer); return(new VsKeyProcessor(_adapter, bufferCoordinator)); }
KeyProcessor IKeyProcessorProvider.GetAssociatedProcessor(IWpfTextView wpfTextView) { if (!_vim.TryGetOrCreateVimBufferForHost(wpfTextView, out IVimBuffer vimBuffer)) { return(null); } var vimBufferCoordinator = _bufferCoordinatorFactory.GetVimBufferCoordinator(vimBuffer); return(new VsVimKeyProcessor(_adapter, vimBufferCoordinator, _keyUtil, _reportDesignerUtil)); }
KeyProcessor IKeyProcessorProvider.GetAssociatedProcessor(IWpfTextView wpfTextView) { var opt = _vim.GetOrCreateVimBufferForHost(wpfTextView); if (opt.IsNone()) { return(null); } var vimBuffer = opt.Value; var vimBufferCoordinator = _bufferCoordinatorFactory.GetVimBufferCoordinator(vimBuffer); return(new VsKeyProcessor(_adapter, vimBufferCoordinator, _keyUtil)); }
KeyProcessor IKeyProcessorProvider.GetAssociatedProcessor(IWpfTextView wpfTextView) { // Don't want to invoke the custom processor unless R# is installed on the machine if (!_reSharperUtil.IsInstalled) { return(null); } if (!_vim.TryGetOrCreateVimBufferForHost(wpfTextView, out IVimBuffer vimBuffer)) { return(null); } var vimBufferCoordinator = _vimBufferCoordinatorFactory.GetVimBufferCoordinator(vimBuffer); return(ReSharperKeyUtil.GetOrCreate(vimBufferCoordinator)); }
/// <summary> /// Raised when an IVsTextView is created. When this occurs it means a previously created /// ITextView was associated with an IVsTextView shim. This means the ITextView will be /// hooked into the Visual Studio command system and a host of other items. Setup all of /// our plumbing here /// </summary> void IVsTextViewCreationListener.VsTextViewCreated(IVsTextView vsView) { // Get the ITextView created. Shouldn't ever be null unless a non-standard Visual Studio // component is calling this function var textView = _adaptersFactory.GetWpfTextViewNoThrow(vsView); if (textView == null) { return; } // Sanity check. No reason for this to be null var opt = _vim.GetVimBuffer(textView); if (!opt.IsSome()) { return; } var vimBuffer = opt.Value; // At this point Visual Studio has fully applied it's settings. Begin the synchronization process BeginSettingSynchronization(vimBuffer); var broker = _displayWindowBrokerFactoryServcie.CreateDisplayWindowBroker(textView); var bufferCoordinator = _bufferCoordinatorFactory.GetVimBufferCoordinator(vimBuffer); var result = VsCommandTarget.Create(bufferCoordinator, vsView, _textManager, _adapter, broker, _resharperUtil, _keyUtil); if (result.IsSuccess) { // Store the value for debugging _vimBufferToCommandTargetMap[vimBuffer] = result.Value; } // 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, vimBuffer); _protectedOperations.BeginInvoke(install); }
private void ConnectToOleCommandTarget(IVimBuffer vimBuffer, ITextView textView, IVsTextView vsTextView) { var broker = _displayWindowBrokerFactoryServcie.GetDisplayWindowBroker(textView); var vimBufferCoordinator = _bufferCoordinatorFactory.GetVimBufferCoordinator(vimBuffer); var result = VsCommandTarget.Create(vimBufferCoordinator, vsTextView, _textManager, _adapter, broker, _keyUtil, _vimApplicationSettings, _commandTargetFactoryList); if (result.IsSuccess) { // Store the value for debugging _vimBufferToCommandTargetMap[vimBuffer] = result.Value; } // 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 void install() => VsFilterKeysAdapter.TryInstallFilterKeysAdapter(_adapter, vimBuffer); _protectedOperations.BeginInvoke(install); }
/// <summary> /// Raised when an IVsTextView is created. When this occurs it means a previously created /// ITextView was associated with an IVsTextView shim. This means the ITextView will be /// hooked into the Visual Studio command system and a host of other items. Setup all of /// our plumbing here /// </summary> void IVsTextViewCreationListener.VsTextViewCreated(IVsTextView vsView) { // Get the ITextView created. Shouldn't ever be null unless a non-standard Visual Studio // component is calling this function var textView = _adaptersFactory.GetWpfTextView(vsView); if (textView == null) { return; } // Sanity check. No reason for this to be null var opt = _vim.GetVimBuffer(textView); if (!opt.IsSome()) { return; } var buffer = opt.Value; BufferData bufferData; if (_bufferMap.TryGetValue(buffer, out bufferData)) { // During the lifetime of an IVimBuffer the local and editor settings are kept // in sync for tab values. At startup though a decision has to be made about which // settings should "win" and this is controlled by 'UseEditorSettings'. // // Visual Studio of course makes this difficult. It will create an ITextView and // then later force all of it's language preference settings down on the ITextView // if it does indeed have an IVsTextView. This setting will inherently overwrite // the custom settings with the stored Visual Studio settings. // // To work around this we store the original values and reset them here. This event // is raised after this propagation occurs so we can put them back if (!_vim.GlobalSettings.UseEditorSettings) { buffer.LocalSettings.TabStop = bufferData.TabStop; buffer.LocalSettings.ExpandTab = bufferData.ExpandTab; buffer.LocalSettings.Number = bufferData.Number; } } else { bufferData = new BufferData(); _bufferMap[buffer] = bufferData; } var broker = _displayWindowBrokerFactoryServcie.CreateDisplayWindowBroker(textView); var bufferCoordinator = _bufferCoordinatorFactory.GetVimBufferCoordinator(buffer); var result = VsCommandTarget.Create(bufferCoordinator, vsView, _adapter, broker, _externalEditorManager); if (result.IsSuccess) { // Store the value for debugging bufferData.VsCommandTarget = result.Value; } // 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); _protectedOperations.BeginInvoke(install); }