- 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:
Kevin Cunnane
2017-03-16 10:20:22 -07:00
committed by GitHub
parent 7ba2011a1e
commit 8d017368f9
5 changed files with 38 additions and 2 deletions

View File

@@ -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; });
}

View File

@@ -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));
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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()
{