madskristensen / WebEssentials2015

A Visual Studio extension for web developers
Other
300 stars 92 forks source link

Hang in markdown parser #98

Closed huguesv closed 9 years ago

huguesv commented 9 years ago

VS 2015, Web Essentials 2015 0.5.168

Open a markdown file with the following contents (sorry for providing it as a picture, I'm not sure if there's a way to escape the markdown content inside markdown):

markdown-hang

On line 18, I type triple backtick to start a code block, and VS hangs in markdown parser code:

>   WebEssentials2015.dll!MadsKristensen.EditorExtensions.Markdown.MarkdownParser.ContentBlockParser.ReadInlineCodeBlock() Line 328 C#
    WebEssentials2015.dll!MadsKristensen.EditorExtensions.Markdown.MarkdownParser.ContentBlockParser.ReadContent() Line 349 C#
    WebEssentials2015.dll!MadsKristensen.EditorExtensions.Markdown.MarkdownParser.BlockParser.Parse() Line 174  C#
    WebEssentials2015.dll!MadsKristensen.EditorExtensions.Markdown.MarkdownParser.Parse() Line 479  C#
    WebEssentials2015.dll!MadsKristensen.EditorExtensions.Markdown.MarkdownCodeArtifactProcessor.GetArtifacts(Microsoft.Web.Core.Text.ITextProvider text, Microsoft.Html.Core.Artifacts.ArtifactCollection artifactCollection) Line 51  C#
madskristensen commented 9 years ago

Thanks for reporting this. The fix is in the latest CI build at http://vsixgallery.com/extension/5fb7364d-2e8c-44a4-95eb-2a382e30fec9/

Can you help verify that it is fixed?

huguesv commented 9 years ago

Thanks for the quick fix!

I got past the hang with the CI build, but I managed to get another error a few seconds later :(

If I press enter at the caret location in this screenshot: block

I get:

---------------------------
Microsoft Visual Studio
---------------------------
Specified argument was out of the range of valid values.

Parameter name: lineNumber
---------------------------
OK   
---------------------------
madskristensen commented 9 years ago

@SLaks I can't figure out where the ArgumentOutOfRangeException is coming from. I've tried all sorts of things, but I'm completely stuck. I'm afraid I have messed up your code and I don't completely understand it. Can you please take a look or point me in the right direction?

SLaks commented 9 years ago

This looks like a bug in the web editor code; the stack trace consists entirely of indent / ContainedLanguage code.

It probably has to do with the zero-length artifact in the new line (my parser returns a separate artifact for each line, so that > prefixes from code blocks inside quote blocks are ignored).

madskristensen commented 9 years ago

I'm not sure it did that earlier. Isn't it possible to not allow zero-length code blocks?

SLaks commented 9 years ago

Looking further, it looks like the problem is caused by my CodeBlockBlockHandler, which only works with my BufferGenerator. Why did you remove that?

Removing the CodeBlockBlockHandler should fix this.

madskristensen commented 9 years ago

I'm not sure :)

Thanks, that works!