More bug fix for #379

This commit is contained in:
Ajay Bhargav Baaskaran 2015-05-20 12:50:30 -07:00
parent 0e296283f9
commit aaa14cd36b
4 changed files with 20 additions and 26 deletions

View File

@ -1049,19 +1049,22 @@ namespace Microsoft.AspNet.Razor.Parser
tags.Clear();
if (!Context.DesignTimeMode)
{
if (Context.LastSpan.Kind == SpanKind.Transition)
if (At(HtmlSymbolType.WhiteSpace))
{
// Output current span content as markup.
Output(SpanKind.Markup);
if (Context.LastSpan.Kind == SpanKind.Transition)
{
// Output current span content as markup.
Output(SpanKind.Markup);
// Accept and mark the whitespace at the end of a <text> tag as code.
AcceptWhile(HtmlSymbolType.WhiteSpace);
Span.CodeGenerator = new StatementCodeGenerator();
Output(SpanKind.Code);
}
else
{
AcceptWhile(HtmlSymbolType.WhiteSpace);
// Accept and mark the whitespace at the end of a <text> tag as code.
AcceptWhile(HtmlSymbolType.WhiteSpace);
Span.CodeGenerator = new StatementCodeGenerator();
Output(SpanKind.Code);
}
else
{
AcceptWhile(HtmlSymbolType.WhiteSpace);
}
}
if (!EndOfFile && CurrentSymbol.Type == HtmlSymbolType.NewLine)

View File

@ -647,7 +647,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
),
new MarkupTagBlock(
Factory.MarkupTransition("</text>").Accepts(AcceptedCharacters.None)),
Factory.Markup(Environment.NewLine).With(new StatementCodeGenerator()).Accepts(AcceptedCharacters.None)
Factory.Markup(Environment.NewLine).Accepts(AcceptedCharacters.None)
),
Factory.Code($" }}{Environment.NewLine} if(!false) {{{Environment.NewLine}").AsStatement(),
new MarkupBlock(

View File

@ -49,12 +49,9 @@ namespace TestOutput
#line default
#line hidden
Instrumentation.EndContext();
#line 3 "CodeBlockWithTextElement.cshtml"
#line default
#line hidden
Instrumentation.BeginContext(80, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
#line 4 "CodeBlockWithTextElement.cshtml"
#line default

View File

@ -81,15 +81,9 @@ namespace TestOutput
Instrumentation.EndContext();
WriteAttribute("href", Tuple.Create(" href=\"", 387), Tuple.Create("\"", 442), Tuple.Create(Tuple.Create("", 394), Tuple.Create<System.Object, System.Int32>(Href("~/A+Really(Crazy),Url.Is:This/"), 394), false),
Tuple.Create(Tuple.Create("", 424), Tuple.Create<System.Object, System.Int32>(product.id, 424), false), Tuple.Create(Tuple.Create("", 435), Tuple.Create("/Detail", 435), true));
Instrumentation.BeginContext(443, 21, true);
WriteLiteral(">Crazy Url!</a>\r\n ");
Instrumentation.BeginContext(443, 23, true);
WriteLiteral(">Crazy Url!</a>\r\n \r\n");
Instrumentation.EndContext();
#line 12 "ResolveUrl.cshtml"
#line default
#line hidden
#line 13 "ResolveUrl.cshtml"
#line default