mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-03 01:25:44 -05:00
Fix to not add parens for global variable built in functions (#940)
This commit is contained in:
@@ -74,8 +74,11 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion
|
||||
case DeclarationType.BuiltInFunction:
|
||||
case DeclarationType.ScalarValuedFunction:
|
||||
case DeclarationType.TableValuedFunction:
|
||||
// Functions we add on the () at the end since they'll always have them
|
||||
InsertText = WithDelimitedIdentifier(FunctionPostfix, DeclarationTitle);
|
||||
// Add ()'s for all functions except global variable system functions (which all start with @@)
|
||||
if (!DeclarationTitle.StartsWith("@@"))
|
||||
{
|
||||
InsertText = WithDelimitedIdentifier(FunctionPostfix, DeclarationTitle);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +263,20 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GlobalVariableSystemFunctionsShouldNotHaveParenthesesAdded()
|
||||
{
|
||||
string declarationTitle = "@@CONNECTIONS";
|
||||
string tokenText = "";
|
||||
SqlCompletionItem item = new SqlCompletionItem(declarationTitle, DeclarationType.BuiltInFunction, tokenText);
|
||||
CompletionItem completionItem = item.CreateCompletionItem(0, 1, 2);
|
||||
|
||||
Assert.Equal(declarationTitle, completionItem.Label);
|
||||
Assert.Equal($"{declarationTitle}", completionItem.InsertText);
|
||||
Assert.Equal(declarationTitle, completionItem.Detail);
|
||||
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(DeclarationType.Server)]
|
||||
[InlineData(DeclarationType.Database)]
|
||||
|
||||
Reference in New Issue
Block a user