Skip to content

Commit

Permalink
[Haxe][ASComplete][GetExpression] Fixed: Exception when typing an exp…
Browse files Browse the repository at this point in the history
…ression with a literal string. fixes #2386 (#2395)
  • Loading branch information
SlavaRa committed Sep 19, 2018
1 parent c64f801 commit 24f1bb4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
7 changes: 7 additions & 0 deletions External/Plugins/ASCompletion/Completion/ASComplete.cs
Expand Up @@ -3484,6 +3484,13 @@ private static ASExpr GetExpression(ScintillaControl sci, int position, bool ign
c = (char)sci.CharAt(position);
if ((dQuotes > 0 && c != '\"') || (sQuotes > 0 && c != '\''))
{
if (!IsStringStyle(style) && !IsCharStyle(style) && !context.CodeComplete.IsStringInterpolationStyle(sci, position))
{
sb.Clear();
positionExpression = expression.Position;
expression.SubExpressions = null;
break;
}
sbSub.Insert(0, c);
continue;
}
Expand Down
Expand Up @@ -1549,7 +1549,26 @@ yield return
}
}

[Test, TestCaseSource(nameof(GetExpressionTestCases))]
static IEnumerable<TestCaseData> GetExpressionIssue2386TestCases
{
get
{
yield return new TestCaseData("cast(v, String).charAt(1), '$(EntryPoint)")
.Returns(" ")
.SetName("cast(v, String).charAt(1), '|")
.SetDescription("https://github.com/fdorg/flashdevelop/issues/2386");
yield return new TestCaseData("cast(v, String).charAt(1), \"$(EntryPoint)")
.Returns(" ")
.SetName("cast(v, String).charAt(1), \"|")
.SetDescription("https://github.com/fdorg/flashdevelop/issues/2386");
}
}

[
Test,
TestCaseSource(nameof(GetExpressionTestCases)),
TestCaseSource(nameof(GetExpressionIssue2386TestCases)),
]
public string GetExpression(string sourceText) => GetExpression(sci, sourceText);

static IEnumerable<TestCaseData> DisambiguateComaHaxeTestCases
Expand Down

0 comments on commit 24f1bb4

Please sign in to comment.