mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-11 18:48:36 -05:00
Ensure Keywork and DataType options are used
This commit is contained in:
@@ -33,12 +33,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
||||
{
|
||||
settings = new FormatterSettings();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public override void InitializeService(IProtocolEndpoint serviceHost)
|
||||
{
|
||||
serviceHost.SetRequestHandler(DocumentFormattingRequest.Type, HandleDocFormatRequest);
|
||||
serviceHost.SetRequestHandler(DocumentRangeFormattingRequest.Type, HandleDocRangeFormatRequest);
|
||||
|
||||
|
||||
|
||||
|
||||
WorkspaceService?.RegisterConfigChangeCallback(HandleDidChangeConfigurationNotification);
|
||||
}
|
||||
|
||||
@@ -122,25 +126,22 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
||||
}
|
||||
|
||||
private FormatOptions GetOptions(DocumentFormattingParams docFormatParams)
|
||||
{
|
||||
return MergeFormatOptions(docFormatParams.Options, settings);
|
||||
}
|
||||
|
||||
internal static FormatOptions MergeFormatOptions(FormattingOptions formatRequestOptions, FormatterSettings settings)
|
||||
|
||||
{
|
||||
FormatOptions options = new FormatOptions();
|
||||
if (docFormatParams.Options != null)
|
||||
if (formatRequestOptions != null)
|
||||
{
|
||||
options.UseSpaces = docFormatParams.Options.InsertSpaces;
|
||||
options.SpacesPerIndent = docFormatParams.Options.TabSize;
|
||||
}
|
||||
if (settings != null)
|
||||
{
|
||||
if (settings.AlignColumnDefinitionsInColumns.HasValue) { options.AlignColumnDefinitionsInColumns = settings.AlignColumnDefinitionsInColumns.Value; }
|
||||
|
||||
if (settings.PlaceCommasBeforeNextStatement.HasValue) { options.PlaceCommasBeforeNextStatement = settings.PlaceCommasBeforeNextStatement.Value; }
|
||||
|
||||
if (settings.PlaceSelectStatementReferencesOnNewLine.HasValue) { options.PlaceEachReferenceOnNewLineInQueryStatements = settings.PlaceSelectStatementReferencesOnNewLine.Value; }
|
||||
|
||||
if (settings.UseBracketForIdentifiers.HasValue) { options.EncloseIdentifiersInSquareBrackets = settings.UseBracketForIdentifiers.Value; }
|
||||
|
||||
options.UseSpaces = formatRequestOptions.InsertSpaces;
|
||||
options.SpacesPerIndent = formatRequestOptions.TabSize;
|
||||
}
|
||||
UpdateFormatOptionsFromSettings(options, settings);
|
||||
return options;
|
||||
|
||||
}
|
||||
|
||||
internal static void UpdateFormatOptionsFromSettings(FormatOptions options, FormatterSettings settings)
|
||||
|
||||
Reference in New Issue
Block a user