Beispiel #1
0
        public void R_OutlineToggleAll() {
            string text = _files.LoadDestinationFile("lsfit.r");
            using (var script = new TestScript(text, RContentTypeDefinition.ContentType)) {
                script.DoIdle(500);

                IOutliningManagerService svc = EditorShell.Current.ExportProvider.GetExportedValue<IOutliningManagerService>();
                IOutliningManager mgr = svc.GetOutliningManager(EditorWindow.CoreEditor.View);
                var snapshot = EditorWindow.TextBuffer.CurrentSnapshot;

                var viewLines = EditorWindow.CoreEditor.View.TextViewLines;
                viewLines.Count.Should().Be(40);
                script.DoIdle(500);

                EditorWindow.ExecCommand(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.OUTLN_TOGGLE_ALL);
                script.DoIdle(1000);

                IEnumerable<ICollapsed> collapsed = mgr.GetCollapsedRegions(new SnapshotSpan(snapshot, new Span(0, snapshot.Length)));
                collapsed.Count().Should().Be(20);

                EditorWindow.ExecCommand(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.OUTLN_TOGGLE_ALL);
                script.DoIdle(500);

                viewLines = EditorWindow.CoreEditor.View.TextViewLines;
                viewLines.Count.Should().Be(40);

                EditorWindow.ExecCommand(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.OUTLN_STOP_HIDING_ALL);
                script.DoIdle(200);
                mgr.Enabled.Should().Be(false);

                EditorWindow.ExecCommand(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.OUTLN_START_AUTOHIDING);
                script.DoIdle(200);
                mgr.Enabled.Should().Be(true);

                script.MoveDown(9);
                EditorWindow.ExecCommand(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.OUTLN_TOGGLE_CURRENT);
                script.DoIdle(500);

                collapsed = mgr.GetCollapsedRegions(new SnapshotSpan(snapshot, new Span(0, snapshot.Length)));
                collapsed.Count().Should().Be(1);

                EditorWindow.ExecCommand(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.OUTLN_TOGGLE_CURRENT);
                script.DoIdle(200);

                collapsed = mgr.GetCollapsedRegions(new SnapshotSpan(snapshot, new Span(0, snapshot.Length)));
                collapsed.Count().Should().Be(0);
            }
        }
        public void R_SelectWord01() {
            using (var script = new TestScript("\r\nabc$def['test test']", RContentTypeDefinition.ContentType)) {

                script.MoveDown();
                script.Execute(Languages.Editor.Controller.Constants.VSConstants.VSStd2KCmdID.SELECTCURRENTWORD);
                var span = EditorWindow.CoreEditor.View.Selection.StreamSelectionSpan;
                var selectedWord = span.GetText();
                selectedWord.Should().Be("abc");

                script.MoveRight(2);
                script.Execute(Languages.Editor.Controller.Constants.VSConstants.VSStd2KCmdID.SELECTCURRENTWORD);
                span = EditorWindow.CoreEditor.View.Selection.StreamSelectionSpan;
                selectedWord = span.GetText();
                selectedWord.Should().Be("def");

                script.MoveRight(3);
                script.Execute(Languages.Editor.Controller.Constants.VSConstants.VSStd2KCmdID.SELECTCURRENTWORD);
                span = EditorWindow.CoreEditor.View.Selection.StreamSelectionSpan;
                selectedWord = span.GetText();
                selectedWord.Should().Be("test");
            }
        }
        public void R_AutoFormatScopeBraces10() {
            using (var script = new TestScript(RContentTypeDefinition.ContentType)) {
                REditorSettings.FormatOptions.BracesOnNewLine = false;

                script.Type("if(TRUE){");
                script.DoIdle(300);
                script.Type("{ENTER}a");
                script.MoveDown();
                script.MoveRight();
                script.Type("{ENTER}");
                string expected = "if (TRUE) {\r\n    a\r\n}\r\n";

                string actual = script.EditorText;
                actual.Should().Be(expected);
            }
        }
        public void R_AutoFormatScopeBraces08() {
            using (var script = new TestScript("while (true) {\r\n}", RContentTypeDefinition.ContentType)) {
                REditorSettings.FormatOptions.BracesOnNewLine = true;

                script.MoveDown();
                script.Enter();

                string expected = "while (true) {\r\n\r\n}";
                string actual = script.EditorText;

                actual.Should().Be(expected);
            }
        }