Use the new line character to check if the CodeWriter buffer ends in a line feed.
Fixes #577
This commit is contained in:
parent
42acfe43ad
commit
36c744ff29
|
|
@ -79,7 +79,7 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
||||||
|
|
||||||
public void MarkLineMappingEnd()
|
public void MarkLineMappingEnd()
|
||||||
{
|
{
|
||||||
_generatedContentLength = _writer.GenerateCode().Length - _generatedLocation.AbsoluteIndex;
|
_generatedContentLength = _writer.Builder.Length - _generatedLocation.AbsoluteIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
@ -89,7 +89,7 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
||||||
// Verify that the generated length has not already been calculated
|
// Verify that the generated length has not already been calculated
|
||||||
if (_generatedContentLength == 0)
|
if (_generatedContentLength == 0)
|
||||||
{
|
{
|
||||||
_generatedContentLength = _writer.GenerateCode().Length - _generatedLocation.AbsoluteIndex;
|
_generatedContentLength = _writer.Builder.Length - _generatedLocation.AbsoluteIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
var generatedLocation = new MappingLocation(_generatedLocation, _generatedContentLength);
|
var generatedLocation = new MappingLocation(_generatedLocation, _generatedContentLength);
|
||||||
|
|
@ -114,7 +114,8 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
||||||
{
|
{
|
||||||
// Need to add an additional line at the end IF there wasn't one already written.
|
// Need to add an additional line at the end IF there wasn't one already written.
|
||||||
// This is needed to work with the C# editor's handling of #line ...
|
// This is needed to work with the C# editor's handling of #line ...
|
||||||
var endsWithNewline = _writer.GenerateCode().EndsWith("\n");
|
var builder = _writer.Builder;
|
||||||
|
var endsWithNewline = builder.Length > 0 && builder[builder.Length - 1] == '\n';
|
||||||
|
|
||||||
// Always write at least 1 empty line to potentially separate code from pragmas.
|
// Always write at least 1 empty line to potentially separate code from pragmas.
|
||||||
_writer.WriteLine();
|
_writer.WriteLine();
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Razor.CodeGenerators
|
namespace Microsoft.AspNet.Razor.CodeGenerators
|
||||||
{
|
{
|
||||||
|
|
@ -18,6 +19,8 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
||||||
private int _currentLineIndex;
|
private int _currentLineIndex;
|
||||||
private int _currentLineCharacterIndex;
|
private int _currentLineCharacterIndex;
|
||||||
|
|
||||||
|
public StringBuilder Builder => _writer.GetStringBuilder();
|
||||||
|
|
||||||
public string LastWrite { get; private set; }
|
public string LastWrite { get; private set; }
|
||||||
|
|
||||||
public int CurrentIndent { get; private set; }
|
public int CurrentIndent { get; private set; }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue