Fix scoping spacing for pragmas and curly braces.

If the writer did not write anything it would throw when attempting to do .Last().
This commit is contained in:
N. Taylor Mullen 2014-02-13 14:26:49 -08:00
parent cadc2fc67e
commit da192d7c96
2 changed files with 2 additions and 2 deletions

View File

@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler
private void TryAutoSpace(string spaceCharacter)
{
if (_autoSpace && !Char.IsWhiteSpace(_writer.LastWrite.Last()))
if (_autoSpace && _writer.LastWrite.Length > 0 && !Char.IsWhiteSpace(_writer.LastWrite.Last()))
{
_writer.Write(spaceCharacter);
}

View File

@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
documentLocation: _documentMapping,
generatedLocation: new MappingLocation(_generatedLocation, _generatedContentLength));
if (_writer.LastWrite.Last() != '\n')
if (_writer.ToString().Last() != '\n')
{
_writer.WriteLine();
}