public void R_ProvisionalText02() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { script.Type("c(\""); string expected = "c(\"\")"; string actual = script.EditorText; actual.Should().Be(expected); // Move caret outside of the provisional text area // and back so provisional text becomes permanent. script.MoveRight(); script.MoveLeft(); // Let parser hit on idle so AST updates script.DoIdle(300); // There should not be completion inside "" script.Type("\""); expected = "c(\"\"\")"; actual = script.EditorText; actual.Should().Be(expected); } }
public void R_SignatureSessionNavigation() { using (var script = new TestScript(RContentTypeDefinition.ContentType)) { FunctionRdDataProvider.HostStartTimeout = 10000; using (new RHostScript(EditorShell.Current.ExportProvider.GetExportedValue<IRSessionProvider>())) { PrepareFunctionIndex(); FunctionIndexUtility.GetFunctionInfoAsync("lm").Wait(3000); script.Type("x <- lm(subset = a, sing"); script.DoIdle(1000); script.Type("{TAB}"); script.DoIdle(1000); ISignatureHelpSession session = script.GetSignatureSession(); session.Should().NotBeNull(); script.DoIdle(200); IParameter parameter = session.SelectedSignature.CurrentParameter; parameter.Should().NotBeNull(); parameter.Name.Should().Be("singular.ok"); script.MoveLeft(17); script.DoIdle(200); parameter = session.SelectedSignature.CurrentParameter; parameter.Name.Should().Be("subset"); script.MoveRight(3); script.DoIdle(200); parameter = session.SelectedSignature.CurrentParameter; parameter.Name.Should().Be("singular.ok"); } } }
public void R_SmartIndentTest() { using (var script = new TestScript(string.Empty, RContentTypeDefinition.ContentType)) { REditorSettings.FormatOptions.BracesOnNewLine = false; script.MoveRight(); script.Type("{{ENTER}a"); script.DoIdle(300); string expected = "{\r\n a\r\n}"; string actual = script.EditorText; actual.Should().Be(expected); } }
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_LibrarySuggestedActions() { using (var script = new TestScript(" library(base)", RContentTypeDefinition.ContentType)) { IEnumerable<SuggestedActionSet> sets = null; ILightBulbSession session = null; var e = EditorShell.Current.ExportProvider; var svc = e.GetExportedValue<ISuggestedActionCategoryRegistryService>(); script.Invoke(() => { var broker = e.GetExportedValue<ILightBulbBroker>(); broker.CreateSession(svc.AllCodeFixes, EditorWindow.CoreEditor.View); session = script.GetLightBulbSession(); session.Should().NotBeNull(); session.Expand(); session.TryGetSuggestedActionSets(out sets); }); sets.Should().NotBeNull(); sets.Should().HaveCount(0); session.Dismiss(); script.DoIdle(200); script.MoveRight(2); script.DoIdle(200); sets = null; script.Invoke(() => { var broker = e.GetExportedValue<ILightBulbBroker>(); broker.CreateSession(svc.Any, EditorWindow.CoreEditor.View); session = script.GetLightBulbSession(); session.Should().NotBeNull(); session.Expand(); session.TryGetSuggestedActionSets(out sets); }); script.DoIdle(3000); sets = null; script.Invoke(() => { session.TryGetSuggestedActionSets(out sets); }); sets.Should().NotBeNull(); sets.Should().HaveCount(1); var set = sets.First(); set.Actions.Should().HaveCount(2); var actions = set.Actions.ToArray(); actions[0].Should().BeOfType(typeof(InstallPackageSuggestedAction)); actions[1].Should().BeOfType(typeof(LoadLibrarySuggestedAction)); } }
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); } }