Skip to content

Commit

Permalink
Editor: hotfix possible "index out of range" in AutoComplete
Browse files Browse the repository at this point in the history
bug introduced by cf66b8f
  • Loading branch information
ivan-mogilko committed Dec 20, 2024
1 parent 61d8c3e commit adaebbb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Editor/AGS.CScript.Compiler/Entities/FastString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ namespace AGS.CScript.Compiler
{
/// <summary>
/// Optimised class to allow Substrings to be done without creating new
/// copies of the string data in memory
/// copies of the string data in memory.
/// TODO: implement Length, to be able to work with any range inside parent string.
/// TODO: implement EndsWith.
/// </summary>
public class FastString
{
Expand Down Expand Up @@ -51,6 +53,7 @@ public bool StartsWith(string text)
{
return false;
}
// FIXME: compare Char by Char instead? calling String.Substring here defeats the purpose of FastString!
return (_data[_offset] == text[0]) && (_data.Substring(_offset).StartsWith(text, _useComparison));
}

Expand Down
3 changes: 2 additions & 1 deletion Editor/AGS.Editor/AutoComplete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,8 @@ private static void GetFunctionParametersAsVariableList(ScriptFunction func, Lis
FastString paramName = param.Substring(index + 1);
FastString paramType = param.Substring(0, index + 1).Trim();
bool isPointer = false;
if (paramType[paramType.Length - 1] == '*')
// FIXME: implement FastString EndsWith
if ((paramType.Length > 0) && paramType[paramType.Length - 1] == '*')
{
isPointer = true;
paramType = paramType.Substring(0, paramType.Length - 1).Trim();
Expand Down

0 comments on commit adaebbb

Please sign in to comment.