mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
- Ensure minimum of 2 newlines after GO statement - All existing unit tests are passing, indicating this is respecting scenarios where users have comment lines after GO statements (this happens in many other tests)
This commit is contained in:
@@ -30,7 +30,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
||||
return NormalizeNewLinesInWhitespace(original, context, 1);
|
||||
}
|
||||
|
||||
private static string NormalizeNewLinesInWhitespace(string original, FormatContext context, int minimumNewLines)
|
||||
internal static string NormalizeNewLinesInWhitespace(string original, FormatContext context, int minimumNewLines)
|
||||
{
|
||||
return NormalizeNewLinesInWhitespace(original, context, 1, () => { return original; });
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
|
||||
{
|
||||
for (int i = startTokenNumber; i < firstChildStartTokenNumber; i++)
|
||||
{
|
||||
SimpleProcessToken(i, FormatterUtilities.NormalizeNewLinesEnsureOneNewLineMinimum);
|
||||
SimpleProcessToken(i, (original, context) => FormatterUtilities.NormalizeNewLinesInWhitespace(original, context, 2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
use WideWorldImporters;
|
||||
go
|
||||
|
||||
alter database current collate Latin1_General_100_CI_AS;
|
||||
go
|
||||
|
||||
alter database current set RECOVERY SIMPLE;
|
||||
go
|
||||
|
||||
alter database current set AUTO_UPDATE_STATISTICS_ASYNC on;
|
||||
go
|
||||
@@ -0,0 +1,11 @@
|
||||
USE WideWorldImporters;
|
||||
GO
|
||||
|
||||
ALTER DATABASE CURRENT COLLATE Latin1_General_100_CI_AS;
|
||||
GO
|
||||
|
||||
ALTER DATABASE CURRENT SET RECOVERY SIMPLE;
|
||||
GO
|
||||
|
||||
ALTER DATABASE CURRENT SET AUTO_UPDATE_STATISTICS_ASYNC ON;
|
||||
GO
|
||||
@@ -10,6 +10,20 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
|
||||
{
|
||||
public class GeneralFormatterTests : FormatterUnitTestsBase
|
||||
{
|
||||
[Fact]
|
||||
public void GoNewLineShouldBePreserved()
|
||||
{
|
||||
LoadAndFormatAndCompare("GoNewLineShouldBePreserved",
|
||||
GetInputFile("Go.sql"),
|
||||
GetBaselineFile("Go_NewlineHandling.sql"),
|
||||
new FormatOptions() {
|
||||
KeywordCasing = CasingOptions.Lowercase,
|
||||
DatatypeCasing = CasingOptions.Uppercase,
|
||||
PlaceEachReferenceOnNewLineInQueryStatements = true
|
||||
},
|
||||
verifyFormat: true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void KeywordCaseConversionUppercase()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user