protected void VerifyOpenLineAbove(
            string initialMarkup,
            string expectedMarkup,
            bool useTabs = false,
            bool autoGenerateXmlDocComments = true
            )
        {
            Verify(
                initialMarkup,
                expectedMarkup,
                useTabs,
                autoGenerateXmlDocComments,
                execute: (workspace, view, editorOperationsFactoryService) =>
            {
                var commandHandler = CreateCommandHandler(workspace);

                var commandArgs = new OpenLineAboveCommandArgs(view, view.TextBuffer);
                void nextHandler()
                {
                    var editorOperations = editorOperationsFactoryService.GetEditorOperations(
                        view
                        );
                    editorOperations.OpenLineAbove();
                }

                commandHandler.ExecuteCommand(
                    commandArgs,
                    nextHandler,
                    TestCommandExecutionContext.Create()
                    );
            }
                );
        }
        protected async Task VerifyOpenLineAboveAsync(string initialMarkup, string expectedMarkup, bool useTabs = false, bool autoGenerateXmlDocComments = true)
        {
            await VerifyAsync(initialMarkup, expectedMarkup, useTabs, autoGenerateXmlDocComments,
                              execute : (view, undoHistoryRegistry, editorOperationsFactoryService, completionService) =>
            {
                var commandHandler = CreateCommandHandler(TestWaitIndicator.Default, undoHistoryRegistry, editorOperationsFactoryService) as ICommandHandler <OpenLineAboveCommandArgs>;

                var commandArgs    = new OpenLineAboveCommandArgs(view, view.TextBuffer);
                Action nextHandler = () =>
                {
                    var editorOperations = editorOperationsFactoryService.GetEditorOperations(view);
                    editorOperations.OpenLineAbove();
                };

                commandHandler.ExecuteCommand(commandArgs, nextHandler);
            });
        }
        internal void VerifyOpenLineAbove(string initialMarkup, string expectedMarkup, bool useTabs = false, string newLine = "\r\n", bool trimTrailingWhiteSpace = false, OptionsCollection globalOptions = null)
        {
            Verify(initialMarkup, expectedMarkup,
                   execute: (workspace, view, editorOperationsFactoryService) =>
            {
                var commandHandler = CreateCommandHandler(workspace);

                var commandArgs = new OpenLineAboveCommandArgs(view, view.TextBuffer);
                void nextHandler()
                {
                    var editorOperations = editorOperationsFactoryService.GetEditorOperations(view);
                    editorOperations.OpenLineAbove();
                }

                commandHandler.ExecuteCommand(commandArgs, nextHandler, TestCommandExecutionContext.Create());
            },
                   useTabs, newLine, trimTrailingWhiteSpace, globalOptions);
        }
Beispiel #4
0
        public void ExecuteCommand(OpenLineAboveCommandArgs args, Action nextHandler)
        {
            // Check to see if the current line starts with exterior trivia. If so, we'll take over.
            // If not, let the nextHandler run.

            var caretPosition = args.TextView.GetCaretPoint(args.SubjectBuffer) ?? -1;

            if (caretPosition < 0)
            {
                nextHandler();
                return;
            }

            if (!CurrentLineStartsWithExteriorTrivia(args.SubjectBuffer, caretPosition))
            {
                nextHandler();
                return;
            }

            // Allow nextHandler() to run and then insert exterior trivia if necessary.
            nextHandler();

            InsertExteriorTriviaIfNeeded(args.TextView, args.SubjectBuffer);
        }
Beispiel #5
0
 public CommandState GetCommandState(OpenLineAboveCommandArgs args, Func <CommandState> nextHandler)
 {
     return(nextHandler());
 }
Beispiel #6
0
 public CommandState GetCommandState(OpenLineAboveCommandArgs args, Func <CommandState> nextHandler)
 => nextHandler();
Beispiel #7
0
 bool ICommandHandler <OpenLineAboveCommandArgs> .ExecuteCommand(OpenLineAboveCommandArgs args, CommandExecutionContext executionContext)
 {
     GetOperations(args.TextView).OpenLineAbove();
     return(true);
 }
Beispiel #8
0
 CommandState ICommandHandler <OpenLineAboveCommandArgs> .GetCommandState(OpenLineAboveCommandArgs args)
 {
     return(AvailableInEditableView(args.TextView));
 }