Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Fix #834: Completion for a package name produces error in REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailArkhipov committed Feb 6, 2016
1 parent f212793 commit 5b4be23
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
37 changes: 35 additions & 2 deletions src/R/Editor/Application.Test/Completion/IntellisenseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,15 @@ public void R_CompletionFiles() {

[Test]
[Category.Interactive]
public void R_CompletionFunctionBraces() {
public void R_CompletionFunctionBraces01() {
using (var script = new TestScript(RContentTypeDefinition.ContentType)) {
var provider = EditorShell.Current.ExportProvider.GetExportedValue<IRSessionProvider>();
using (new RHostScript(provider)) {
using (var hostScript = new RHostScript(provider)) {

string message = null;
hostScript.Session.Output += (s, e) => {
message = e.Message;
};

script.DoIdle(100);
script.Type("instal");
Expand All @@ -185,10 +190,38 @@ public void R_CompletionFunctionBraces() {
string actual = script.EditorText;
actual.Should().Be("install.packages()");
EditorWindow.CoreEditor.View.Caret.Position.BufferPosition.Position.Should().Be(actual.Length - 1);

message.Should().BeNull();
}
}
}

[Test]
[Category.Interactive]
public void R_CompletionFunctionBraces02() {
using (var script = new TestScript(RContentTypeDefinition.ContentType)) {
var provider = EditorShell.Current.ExportProvider.GetExportedValue<IRSessionProvider>();
using (var hostScript = new RHostScript(provider)) {

string message = null;
hostScript.Session.Output += (s, e) => {
message = e.Message;
};

script.DoIdle(100);
script.Type("bas");
script.DoIdle(1000);
script.Type("{TAB}");
script.DoIdle(100);

string actual = script.EditorText;
actual.Should().Be("base");

message.Should().BeNull();
}
}
}

//[Test]
//[Category.Interactive]
public void R_DeclaredVariablesCompletion() {
Expand Down
4 changes: 2 additions & 2 deletions src/R/Editor/Impl/Completion/RCompletionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ private async Task<bool> IsFunction(string name) {
IRSession session = sessionProvider.GetOrCreate(GuidList.InteractiveWindowRSessionGuid, null);
if (session != null) {
using (IRSessionEvaluation eval = await session.BeginEvaluationAsync(isMutating: false)) {
REvaluationResult result = await eval.EvaluateAsync($"mode({name})");
REvaluationResult result = await eval.EvaluateAsync($"tryCatch(is.function({name}), error = function(e) {{ }})");
if (result.ParseStatus == RParseStatus.OK &&
!string.IsNullOrEmpty(result.StringResult) &&
result.StringResult == "function") {
(result.StringResult == "T" || result.StringResult == "TRUE")) {
return true;
}
}
Expand Down

0 comments on commit 5b4be23

Please sign in to comment.