Beispiel #1
0
        public void Search2()
        {
            var mode = _factory.Create <INormalMode>();

            _vimBuffer.NormalModeImpl = mode.Object;
            _vimBuffer.ModeKindImpl   = ModeKind.Normal;
            var data = new SearchData("cat", SearchKind.Backward, SearchOptions.None);

            _search.SetupGet(x => x.InSearch).Returns(true).Verifiable();
            _search.SetupGet(x => x.CurrentSearchData).Returns(FSharpOption.Create(data)).Verifiable();
            SimulatKeystroke();
            Assert.AreEqual("?cat", _marginControl.StatusLine);
            _factory.Verify();
        }
Beispiel #2
0
            public void RaiseEvent()
            {
                Create("hello world");
                _asyncTagger.CachedOverarchingRequestSpan = FSharpOption.Create(_textBuffer.GetLine(0).Extent);
                var didRun = false;

                _asyncTaggerInterface.TagsChanged += delegate
                {
                    didRun = true;
                };

                _asyncTaggerSource.RaiseChanged(null);
                Assert.True(didRun);
            }
Beispiel #3
0
 public LoadSessionDataTest()
 {
     _stream = new MemoryStream();
     _fileSystem
     .Setup(x => x.Read(It.IsAny <string>()))
     .Returns(() => FSharpOption.Create(GetStreamCopy()));
     _fileSystem
     .Setup(x => x.Write(It.IsAny <string>(), It.IsAny <Stream>()))
     .Callback <string, Stream>((_, stream) => stream.CopyTo(_stream))
     .Returns(true);
     _fileSystem
     .Setup(x => x.CreateDirectory(It.IsAny <string>()))
     .Returns(true);
 }
Beispiel #4
0
 private void Create(params string[] lines)
 {
     _textView          = EditorUtil.CreateTextView(lines);
     _visualBuffer      = _textView.TextViewModel.VisualBuffer;
     _adhocOutliner     = EditorUtil.FactoryService.AdhocOutlinerFactory.GetAdhocOutliner(_textView.TextBuffer);
     _outliningeManager = EditorUtil.FactoryService.OutliningManagerService.GetOutliningManager(_textView);
     _statusUtil        = new Mock <IStatusUtil>(MockBehavior.Strict);
     _foldData          = EditorUtil.FactoryService.FoldManagerFactory.GetFoldData(_textView.TextBuffer);
     _foldManagerRaw    = new FoldManager(
         _textView,
         _foldData,
         _statusUtil.Object,
         FSharpOption.Create(EditorUtil.FactoryService.OutliningManagerService.GetOutliningManager(_textView)));
     _foldManager = _foldManagerRaw;
 }
Beispiel #5
0
 public static void AddMark(
     this Mock <IMarkMap> map,
     ITextBuffer buffer,
     char mark,
     VirtualSnapshotPoint?point = null)
 {
     if (point.HasValue)
     {
         map.Setup(x => x.GetMark(buffer, mark)).Returns(FSharpOption.Create(point.Value));
     }
     else
     {
         map.Setup(x => x.GetMark(buffer, mark)).Returns(FSharpOption <VirtualSnapshotPoint> .None);
     }
 }
Beispiel #6
0
 public void Create(bool haveRealTransaction = true)
 {
     _factory          = new MockRepository(MockBehavior.Strict);
     _editorOperations = _factory.Create <IEditorOperations>();
     if (haveRealTransaction)
     {
         _realTransaction = _factory.Create <ITextUndoTransaction>();
         _transactionRaw  = new UndoTransaction(FSharpOption.Create(_realTransaction.Object), FSharpOption.Create(_editorOperations.Object));
     }
     else
     {
         _transactionRaw = new UndoTransaction(FSharpOption <ITextUndoTransaction> .None, FSharpOption <IEditorOperations> .None);
     }
     _transaction = _transactionRaw;
 }
Beispiel #7
0
            public void ShellCommand_BangReplacement()
            {
                Create("");
                Vim.VimData.LastShellCommand = FSharpOption.Create("cat");
                var didRun = false;

                VimHost.RunCommandFunc =
                    (command, args, _) =>
                {
                    Assert.Equal("/c git status cat", args);
                    didRun = true;
                    return("");
                };
                ParseAndRun(@"!git status !");
                Assert.True(didRun);
            }
        public void SwitchMode_OldModeIsNotExternalThenSaveNothing()
        {
            Setup("cat", "tree", "dog");
            var span = _textBuffer.GetLineRange(0).Extent;

            SetupMarkers(15, span);
            SetupAdapterCreateMarkerAsSnippet();
            var mode = _factory.Create <IMode>();

            mode.SetupGet(x => x.ModeKind).Returns(ModeKind.Normal).Verifiable();
            _buffer.Raise(x => x.SwitchedMode += null, null, new SwitchModeEventArgs(FSharpOption.Create(mode.Object), null));
            var list = _monitor.IgnoredMarkers.ToList();

            Assert.AreEqual(0, list.Count);
            _factory.Verify();
        }
Beispiel #9
0
        public void LoadVimRc3()
        {
            // Setup the VimRc contents
            var contents = new FileContents(
                "foo",
                new[] { "set ai" });

            _fileSystem.Setup(x => x.GetVimRcDirectories()).Returns(new string[] { "" }).Verifiable();
            _fileSystem.Setup(x => x.LoadVimRcContents()).Returns(FSharpOption.Create(contents)).Verifiable();
            _vimHost.Setup(x => x.CreateHiddenTextView()).Returns(CreateTextView());

            Assert.True(_vim.LoadVimRc());

            Assert.True(_vim.VimRcLocalSettings.AutoIndent);
            _fileSystem.Verify();
        }
Beispiel #10
0
        public void GetTags_DontReplaceBetterRequest()
        {
            Create("cat", "dog", "bear");

            var cancellationTokenSource = new CancellationTokenSource();

            _asyncTagger.AsyncBackgroundRequest = FSharpOption.Create(CreateAsyncBackgroundRequest(
                                                                          _textBuffer.GetExtent(),
                                                                          cancellationTokenSource,
                                                                          new Task(() => { })));

            var tags = _asyncTagger.GetTags(_textBuffer.GetLine(0).Extent).ToList();

            Assert.AreEqual(0, tags.Count);
            Assert.AreSame(cancellationTokenSource, _asyncTagger.AsyncBackgroundRequest.Value.CancellationTokenSource);
        }
Beispiel #11
0
        internal static ICommonOperations CreateCommonOperations(
            ITextView textView,
            IVimLocalSettings localSettings,
            IOutliningManager outlining            = null,
            IStatusUtil statusUtil                 = null,
            ISearchService searchService           = null,
            IUndoRedoOperations undoRedoOperations = null,
            IVimData vimData = null,
            IVimHost vimHost = null,
            ITextStructureNavigator navigator = null,
            IClipboardDevice clipboardDevice  = null,
            IFoldManager foldManager          = null)
        {
            var editorOperations = EditorUtil.GetOperations(textView);
            var editorOptions    = EditorUtil.FactoryService.EditorOptionsFactory.GetOptions(textView);
            var jumpList         = new JumpList(new TrackingLineColumnService());
            var keyMap           = new KeyMap();

            foldManager        = foldManager ?? new FoldManager(textView.TextBuffer);
            statusUtil         = statusUtil ?? new StatusUtil();
            searchService      = searchService ?? CreateSearchService(localSettings.GlobalSettings);
            undoRedoOperations = undoRedoOperations ??
                                 new UndoRedoOperations(statusUtil, FSharpOption <ITextUndoHistory> .None, editorOperations);
            vimData         = vimData ?? new VimData();
            vimHost         = vimHost ?? new MockVimHost();
            navigator       = navigator ?? CreateTextStructureNavigator(textView.TextBuffer);
            clipboardDevice = clipboardDevice ?? new MockClipboardDevice();
            var operationsData = new OperationsData(
                editorOperations,
                editorOptions,
                foldManager,
                jumpList,
                keyMap,
                localSettings,
                outlining != null ? FSharpOption.Create(outlining) : FSharpOption <IOutliningManager> .None,
                CreateRegisterMap(clipboardDevice),
                searchService,
                statusUtil,
                textView,
                undoRedoOperations,
                vimData,
                vimHost,
                navigator);

            return(new CommonOperations(operationsData));
        }
        public void Create(bool haveRealTransaction = true)
        {
            _factory = new MockRepository(MockBehavior.Strict);

            var undoRedoOperations = new UndoRedoOperations(VimHost, new StatusUtil(), FSharpOption <ITextUndoHistory> .None, EditorOperationsFactoryService);

            if (haveRealTransaction)
            {
                _realTransaction = _factory.Create <ITextUndoTransaction>();
                _transactionRaw  = new NormalUndoTransaction("Undo", FSharpOption.Create(_realTransaction.Object), undoRedoOperations);
            }
            else
            {
                _transactionRaw = new NormalUndoTransaction("Undo", FSharpOption <ITextUndoTransaction> .None, undoRedoOperations);
            }
            _transaction = _transactionRaw;
        }
Beispiel #13
0
            public void UseRequestSpan()
            {
                Create("cat", "dog");
                var span = _textBuffer.GetSpan(0, 2);

                _basicTagger.CachedRequestSpan = FSharpOption.Create(span);

                var didRun = false;

                _basicTaggerInterface.TagsChanged += (e, args) =>
                {
                    didRun = true;
                    Assert.Equal(span, args.Span);
                };
                _basicTaggerSource.RaiseChanged();
                Assert.True(didRun);
            }
Beispiel #14
0
        int IVsSelectionEvents.OnElementValueChanged(uint elementid, object varValueOld, object varValueNew)
        {
            var id = (VSConstants.VSSELELEMID)elementid;

            if (id == VSConstants.VSSELELEMID.SEID_WindowFrame)
            {
                ITextView getTextView(object obj)
                {
                    var vsWindowFrame = obj as IVsWindowFrame;

                    if (vsWindowFrame == null)
                    {
                        return(null);
                    }

                    var vsCodeWindow = vsWindowFrame.GetCodeWindow();

                    if (vsCodeWindow.IsError)
                    {
                        return(null);
                    }

                    var lastActiveTextView = vsCodeWindow.Value.GetLastActiveView(_vsAdapter.EditorAdapter);

                    if (lastActiveTextView.IsError)
                    {
                        return(null);
                    }

                    return(lastActiveTextView.Value);
                }

                ITextView oldView = getTextView(varValueOld);
                ITextView newView = null;
                if (ErrorHandler.Succeeded(_vsMonitorSelection.GetCurrentElementValue((uint)VSConstants.VSSELELEMID.SEID_WindowFrame, out object value)))
                {
                    newView = getTextView(value);
                }

                RaiseActiveTextViewChanged(
                    oldView == null ? FSharpOption <ITextView> .None : FSharpOption.Create <ITextView>(oldView),
                    newView == null ? FSharpOption <ITextView> .None : FSharpOption.Create <ITextView>(newView));
            }

            return(VSConstants.S_OK);
        }
Beispiel #15
0
        public void LoadVimRc3()
        {
            // Setup the VimRc contents
            var fileName = "foo";
            var contents = new string[] { "set ai" };
            var tuple    = Tuple.Create(fileName, contents);

            _fileSystem.Setup(x => x.GetVimRcDirectories()).Returns(new string[] { "" }).Verifiable();
            _fileSystem.Setup(x => x.LoadVimRc()).Returns(FSharpOption.Create(tuple)).Verifiable();

            Func <ITextView> createViewFunc = () => EditorUtil.CreateTextView();

            Assert.IsTrue(_vim.LoadVimRc(createViewFunc.ToFSharpFunc()));

            Assert.IsTrue(_vim.VimRcLocalSettings.AutoIndent);
            _fileSystem.Verify();
        }
Beispiel #16
0
        public void GetTags_ReplaceWhenSnapshotChanges()
        {
            Create("cat", "dog", "bear");

            var cancellationTokenSource = new CancellationTokenSource();

            _asyncTagger.AsyncBackgroundRequest = FSharpOption.Create(CreateAsyncBackgroundRequest(
                                                                          _textBuffer.GetExtent(),
                                                                          cancellationTokenSource,
                                                                          new Task(() => { })));

            _textBuffer.Replace(new Span(0, 3), "bat");
            var tags = _asyncTagger.GetTags(_textBuffer.GetExtent()).ToList();

            Assert.AreEqual(0, tags.Count);
            Assert.AreNotSame(cancellationTokenSource, _asyncTagger.AsyncBackgroundRequest.Value.CancellationTokenSource);
            Assert.IsTrue(cancellationTokenSource.IsCancellationRequested);
            Assert.AreEqual(_textBuffer.GetExtent(), _asyncTagger.AsyncBackgroundRequest.Value.Span);
        }
Beispiel #17
0
        private void VeriyCurrentMatchChanged(Action action, Func <SnapshotSpan?> expectedFunc)
        {
            var didSee = false;
            FSharpOption <SnapshotSpan> saw = FSharpOption <SnapshotSpan> .None;

            _mode.CurrentMatchChanged += (sender, e) =>
            {
                didSee = true;
                saw    = e;
            };
            action();

            var expected       = expectedFunc();
            var expectedOption = expected.HasValue
                ? FSharpOption.Create(expected.Value)
                : FSharpOption <SnapshotSpan> .None;

            Assert.True(didSee);
            Assert.Equal(expectedOption, _mode.CurrentMatch);
        }
        public void Create(HistoryKind historyKind = HistoryKind.Mock)
        {
            _factory    = new MockRepository(MockBehavior.Strict);
            _statusUtil = _factory.Create <IStatusUtil>();
            _textView   = CreateTextView();
            _textBuffer = _textView.TextBuffer;

            var editorOperationsFactoryService = _factory.Create <IEditorOperationsFactoryService>();

            FSharpOption <ITextUndoHistory> textUndoHistory;

            switch (historyKind)
            {
            case HistoryKind.Mock:
                _mockUndoHistory = _factory.Create <ITextUndoHistory>();
                _mockUndoHistory.Setup(x => x.Undo(It.IsAny <int>())).Callback <int>(count => { _undoCount += count; });
                _mockUndoHistory.Setup(x => x.Redo(It.IsAny <int>())).Callback <int>(count => { _redoCount += count; });
                textUndoHistory = FSharpOption.Create(_mockUndoHistory.Object);
                break;

            case HistoryKind.Basic:
                textUndoHistory = FSharpOption.Create(BasicUndoHistoryRegistry.TextUndoHistoryRegistry.RegisterHistory(_textBuffer));
                break;

            case HistoryKind.None:
                textUndoHistory = FSharpOption.CreateForReference <ITextUndoHistory>(null);
                break;

            default:
                Assert.True(false);
                textUndoHistory = null;
                break;
            }

            _undoRedoOperationsRaw = new UndoRedoOperations(
                VimHost,
                _statusUtil.Object,
                textUndoHistory,
                editorOperationsFactoryService.Object);
            _undoRedoOperations = _undoRedoOperationsRaw;
        }
        private void Create(params string[] lines)
        {
            _textView = EditorUtil.CreateView(lines);
            _factory  = new MockRepository(MockBehavior.Strict);
            _editOpts = _factory.Create <IEditorOperations>();
            _editOpts.Setup(x => x.AddAfterTextBufferChangePrimitive());
            _editOpts.Setup(x => x.AddBeforeTextBufferChangePrimitive());
            _host           = _factory.Create <IVimHost>();
            _jumpList       = _factory.Create <IJumpList>();
            _registerMap    = MockObjectFactory.CreateRegisterMap(factory: _factory);
            _globalSettings = _factory.Create <IVimGlobalSettings>();
            _globalSettings.SetupGet(x => x.Magic).Returns(true);
            _globalSettings.SetupGet(x => x.SmartCase).Returns(false);
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _settings           = MockObjectFactory.CreateLocalSettings(global: _globalSettings.Object);
            _keyMap             = _factory.Create <IKeyMap>();
            _statusUtil         = _factory.Create <IStatusUtil>();
            _outlining          = _factory.Create <IOutliningManager>();
            _undoRedoOperations = VimUtil.CreateUndoRedoOperations(_statusUtil.Object);
            _searchService      = VimUtil.CreateSearchService(_globalSettings.Object);

            var data = new OperationsData(
                vimData: new VimData(),
                vimHost: _host.Object,
                textView: _textView,
                editorOperations: _editOpts.Object,
                outliningManager: FSharpOption.Create(_outlining.Object),
                statusUtil: _statusUtil.Object,
                jumpList: _jumpList.Object,
                localSettings: _settings.Object,
                keyMap: _keyMap.Object,
                undoRedoOperations: _undoRedoOperations,
                editorOptions: null,
                navigator: null,
                foldManager: null,
                registerMap: _registerMap.Object,
                searchService: _searchService);

            _operationsRaw = new DefaultOperations(data);
            _operations    = _operationsRaw;
        }
 public void Create(bool haveHistory = true)
 {
     _factory          = new MockRepository(MockBehavior.Strict);
     _editorOperations = _factory.Create <IEditorOperations>();
     _statusUtil       = _factory.Create <IStatusUtil>();
     if (haveHistory)
     {
         _history       = _factory.Create <ITextUndoHistory>();
         _operationsRaw = new UndoRedoOperations(
             _statusUtil.Object,
             FSharpOption.Create(_history.Object),
             _editorOperations.Object);
     }
     else
     {
         _operationsRaw = new UndoRedoOperations(
             _statusUtil.Object,
             FSharpOption <ITextUndoHistory> .None,
             _editorOperations.Object);
     }
     _operations = _operationsRaw;
 }
Beispiel #21
0
        /// <summary>
        /// With Resharper installed we need to special certain keys like Escape.  They need to
        /// process it in order for them to dismiss their custom intellisense but their processing
        /// will swallow the event and not propagate it to us.  So handle, return and account
        /// for the double stroke in exec
        /// </summary>
        private CommandAction?QueryStatusInResharper(KeyInput keyInput)
        {
            CommandAction?action = null;

            if (_buffer.ModeKind == ModeKind.Insert && keyInput == KeyInputUtil.EscapeKey)
            {
                // Have to special case Escape here for insert mode.  R# is typically ahead of us on the IOleCommandTarget
                // chain.  If a completion window is open and we wait for Exec to run R# will be ahead of us and run
                // their Exec call.  This will lead to them closing the completion window and not calling back into
                // our exec leaving us in insert mode.
                action = CommandAction.Enable;
            }
            else if (_buffer.ModeKind == ModeKind.ExternalEdit && keyInput == KeyInputUtil.EscapeKey)
            {
                // Have to special case Escape here for external edit mode because we want escape to get us back to
                // normal mode
                action = CommandAction.Enable;
            }
            else if (_adapter.InDebugMode && (keyInput == KeyInputUtil.EnterKey || keyInput.Key == VimKey.Back))
            {
                // In debug mode R# will intercept Enter and Back
                action = CommandAction.Enable;
            }
            else if (keyInput == KeyInputUtil.EnterKey && _buffer.ModeKind != ModeKind.Insert && _buffer.ModeKind != ModeKind.Replace)
            {
                // R# will intercept the Enter key when we are in the middle of an XML doc comment presumable
                // to do some custom formatting.  If we're not insert mode we need to handle that here and
                // suppress the command to keep them from running it
                action = CommandAction.Disable;
            }

            if (action.HasValue && _buffer.Process(keyInput))
            {
                SwallowIfNextExecMatches = FSharpOption.Create(keyInput);
            }

            return(action);
        }
Beispiel #22
0
        public override FSharpOption <int> GetNewLineIndent(ITextView textView, ITextSnapshotLine contextLine, ITextSnapshotLine newLine)
        {
            if (_vimApplicationSettings.UseEditorIndent)
            {
                var indent = _smartIndentationService.GetDesiredIndentation(textView, newLine);
                if (indent.HasValue)
                {
                    return(FSharpOption.Create(indent.Value));
                }
                else
                {
                    // If the user wanted editor indentation but the editor doesn't support indentation
                    // even though it proffers an indentation service then fall back to what auto
                    // indent would do if it were enabled (don't care if it actually is)
                    //
                    // Several editors like XAML offer the indentation service but don't actually
                    // provide information.  User clearly wants indent there since the editor indent
                    // is enabled.  Do a best effort and us Vim style indenting
                    return(FSharpOption.Create(EditUtil.GetAutoIndent(contextLine)));
                }
            }

            return(FSharpOption <int> .None);
        }
Beispiel #23
0
        public override FSharpOption <ITextView> LoadFileIntoNewWindow(string filePath, FSharpOption <int> line, FSharpOption <int> column)
        {
            try
            {
                var textDocument = TextDocumentFactoryService.CreateAndLoadTextDocument(filePath, TextBufferFactoryService.TextContentType);
                var wpfTextView  = MainWindow.CreateTextView(textDocument.TextBuffer);
                MainWindow.AddNewTab(System.IO.Path.GetFileName(filePath), wpfTextView);

                if (line.IsSome())
                {
                    // Move the caret to its initial position.
                    if (column.IsSome())
                    {
                        wpfTextView.MoveCaretToLine(line.Value, column.Value);
                    }
                    else
                    {
                        // Default column implies moving to the first non-blank.
                        wpfTextView.MoveCaretToLine(line.Value);
                        var editorOperations = EditorOperationsFactoryService.GetEditorOperations(wpfTextView);
                        editorOperations.MoveToStartOfLineAfterWhiteSpace(false);
                    }
                }

                // Give the focus to the new buffer.
                var point = wpfTextView.Caret.Position.VirtualBufferPosition;
                NavigateTo(point);

                return(FSharpOption.Create <ITextView>(wpfTextView));
            }
            catch (Exception ex)
            {
                _vim.ActiveStatusUtil.OnError(ex.Message);
                return(FSharpOption <ITextView> .None);
            }
        }
Beispiel #24
0
 public void BackslashLiteral()
 {
     AssertSingle(@"\", new KeyInput(VimKey.RawCharacter, VimKeyModifiers.None, FSharpOption.Create('\\')));
 }
Beispiel #25
0
            private void SetRcContents(params string[] lines)
            {
                var contents = new FileContents("foo", lines);

                _fileSystem.Setup(x => x.LoadVimRcContents()).Returns(FSharpOption.Create(contents)).Verifiable();
            }
Beispiel #26
0
 private static FSharpOption <MotionResult> CreateMotionResultSome()
 {
     return(FSharpOption.Create(CreateMotionResult()));
 }
Beispiel #27
0
 FSharpOption <ITextView> IVimHost.GetFocusedTextView()
 {
     return(TryGetFocusedTextView(out ITextView textView)
         ? FSharpOption.Create(textView)
         : FSharpOption <ITextView> .None);
 }
Beispiel #28
0
            public void HandleCommandKey()
            {
                Map("<D-k>", "gk");
                var ki    = new KeyInput(VimKey.RawCharacter, VimKeyModifiers.Command, FSharpOption.Create('k'));
                var kiSet = new KeyInputSet(ki);

                AssertPartialMapping(kiSet, "g", "k");
            }
Beispiel #29
0
        /// <summary>
        /// With Resharper installed we need to special certain keys like Escape.  They need to
        /// process it in order for them to dismiss their custom intellisense but their processing
        /// will swallow the event and not propagate it to us.  So handle, return and account
        /// for the double stroke in exec
        /// </summary>
        private CommandStatus?QueryStatusInResharper(KeyInput keyInput)
        {
            CommandStatus?status          = null;
            var           passToResharper = true;

            if (_buffer.ModeKind.IsAnyInsert() && keyInput == KeyInputUtil.EscapeKey)
            {
                // Have to special case Escape here for insert mode.  R# is typically ahead of us on the IOleCommandTarget
                // chain.  If a completion window is open and we wait for Exec to run R# will be ahead of us and run
                // their Exec call.  This will lead to them closing the completion window and not calling back into
                // our exec leaving us in insert mode.
                status = CommandStatus.Enable;
            }
            else if (_buffer.ModeKind == ModeKind.ExternalEdit && keyInput == KeyInputUtil.EscapeKey)
            {
                // Have to special case Escape here for external edit mode because we want escape to get us back to
                // normal mode.  However we do want this key to make it to R# as well since they may need to dismiss
                // intellisense
                status = CommandStatus.Enable;
            }
            else if ((keyInput.Key == VimKey.Back || keyInput == KeyInputUtil.EnterKey) && _buffer.ModeKind != ModeKind.Insert)
            {
                // R# special cases both the Back and Enter command in various scenarios
                //
                //  - Enter is special cased in XML doc comments presumably to do custom formatting
                //  - Enter is supressed during debugging in Exec.  Presumably this is done to avoid the annoying
                //    "Invalid ENC Edit" dialog during debugging.
                //  - Back is special cased to delete matched parens in Exec.
                //
                // In all of these scenarios if the Enter or Back key is registered as a valid Vim
                // command we want to process it as such and prevent R# from seeing the command.  If
                // R# is allowed to see the command they will process it often resulting in double
                // actions
                status          = CommandStatus.Enable;
                passToResharper = false;
            }

            // Only process the KeyInput if we are enabling the value.  When the value is Enabled
            // we return Enabled from QueryStatus and Visual Studio will push the KeyInput back
            // through the event chain where either of the following will happen
            //
            //  1. R# will handle the KeyInput
            //  2. R# will not handle it, it will come back to use in Exec and we will ignore it
            //     because we mark it as silently handled
            if (status.HasValue && status.Value == CommandStatus.Enable && _buffer.Process(keyInput).IsAnyHandled)
            {
                // We've broken the rules a bit by handling the command in QueryStatus and we need
                // to silently handle this command if it comes back to us again either through
                // Exec or through the VsKeyProcessor
                _bufferCoordinator.DiscardedKeyInput = FSharpOption.Create(keyInput);

                // If we need to cooperate with R# to handle this command go ahead and pass it on
                // to them.  Else mark it as Disabled.
                //
                // Marking it as Disabled will cause the QueryStatus call to fail.  This means the
                // KeyInput will be routed to the KeyProcessor chain for the ITextView eventually
                // making it to our VsKeyProcessor.  That component respects the SilentlyHandled
                // statu of KeyInput and will siently handle it
                status = passToResharper ? CommandStatus.Enable : CommandStatus.Disable;
            }

            return(status);
        }
Beispiel #30
0
 internal static MotionData CreateMotionData(
     Motion motion,
     int count)
 {
     return(CreateMotionData(motion, new MotionArgument(MotionContext.AfterOperator, FSharpOption.Create(count), FSharpOption <int> .None)));
 }