mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-16 17:23:38 -05:00
Merge pull request #191 from Microsoft/customerIssue/escapeReservedWordsAutocomplete
reserved words with brackets in autocomplete
This commit is contained in:
@@ -332,7 +332,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
|
||||
/// <summary>
|
||||
/// Gets a static instance of an empty completion list to avoid
|
||||
// unneeded memory allocations
|
||||
/// unneeded memory allocations
|
||||
/// </summary>
|
||||
internal static CompletionItem[] EmptyCompletionList
|
||||
{
|
||||
@@ -342,6 +342,16 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether a given word is in the reserved
|
||||
/// word list or not
|
||||
/// </summary>
|
||||
internal static bool IsReservedWord(string text)
|
||||
{
|
||||
int pos = Array.IndexOf(DefaultCompletionText, text.ToLower());
|
||||
return pos > -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current workspace service instance
|
||||
/// Setter for internal testing purposes only
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.SqlServer.Management.SqlParser.Intellisense;
|
||||
@@ -45,7 +46,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion
|
||||
{
|
||||
InsertText = GetCompletionItemInsertName();
|
||||
Label = DeclarationTitle;
|
||||
if (StartsWithBracket(TokenText))
|
||||
if (StartsWithBracket(TokenText) || AutoCompleteHelper.IsReservedWord(InsertText))
|
||||
{
|
||||
Label = WithBracket(Label);
|
||||
InsertText = WithBracket(InsertText);
|
||||
@@ -142,7 +143,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion
|
||||
int row,
|
||||
int startColumn,
|
||||
int endColumn)
|
||||
{
|
||||
{
|
||||
CompletionItem item = new CompletionItem()
|
||||
{
|
||||
Label = label,
|
||||
|
||||
Reference in New Issue
Block a user