Skip to content

Commit

Permalink
Fix alias completion, Fix continue additional text
Browse files Browse the repository at this point in the history
  • Loading branch information
CppCXY committed Aug 12, 2024
1 parent 592efcc commit a374dc8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,20 @@ private void AddAggregateTypeCompletion(LuaAggregateType aggregateType, Complete
detail = string.Join("\n", details.Select(d => d.RepresentText.Trim('#', '@')));
}

if (literalType is { IsString: true, String: { } stringLiteral })
if (literalType is { IsString: true, String: { Value: { } label } stringLiteral })
{
var label = stringLiteral.RepresentText;
// compact emmylua old alias
if (declaration.Type is LuaStringLiteralType stringLiteralType
&& (stringLiteralType.Content.StartsWith('\'') || stringLiteralType.Content.StartsWith('"')))
{
label = stringLiteralType.Content;
}
label = label.Trim('\'', '\"');

if (context.TriggerToken is not LuaStringToken)
{
label = $"\"{label}\"";
var quote = "\'";
if (stringLiteral.RepresentText.StartsWith('\"'))
{
quote = "\"";
}

label = $"{quote}{label}{quote}";
}

context.Add(new CompletionItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ public void AddCompletion(CompleteContext context)
{
AddGlobalCompletion(context);
}
// else if (context.TriggerToken is LuaWhitespaceToken)
// {
// AddGlobalCompletion(context);
// }
// else if (context.TriggerToken is { Kind: LuaTokenKind.TkEndOfLine })
// {
// AddGlobalCompletion(context);
// }
}

private void AddGlobalCompletion(CompleteContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ private void ContinueCompletion(CompleteContext context)
var blockIndentText = string.Empty;
if (loopStat.FirstChild<LuaBlockSyntax>()?.StatList.LastOrDefault() is { } lastStat)
{
if (lastStat is LuaLabelStatSyntax { Name.Text: "continue"})
{
return null;
}

var indentToken = lastStat.GetPrevSibling();
if (indentToken is LuaWhitespaceToken
{
Expand Down

0 comments on commit a374dc8

Please sign in to comment.