gabrielelana / vim-markdown

Markdown for Vim: a complete environment to create Markdown files with a syntax highlight that doesn't suck!
MIT License
740 stars 59 forks source link

A variation on the memory loop from Issue #4? #18

Closed dafydd2277 closed 10 years ago

dafydd2277 commented 10 years ago

Vim 7.3 on OSX. I pulled the update from the resolution of Issue #4.

This time, I tried nesting a backtick'ed word inside a square bracket block for a link. I was flow typing at this time, which is to say I had not yet closed the square bracket block of text.

Which promptly hung Vim. I had to open another shell to kill it.

dafydd2277 commented 10 years ago

It wasn't the backtick. If I leave a left square bracket uncompleted by a right square bracket, VIM will eventually hang. It gets worse if I'm typing along. So far, the workaround is to get both brackets in ([]), then back up to fill in their contents.

gabrielelana commented 10 years ago

@dafydd2277 you are right, 9003a9b didn’t really fix #4 but only made things a little better. This fix was an hard one. The problem is that when you open a square bracket vim tries to match a really complex pattern to catch a markdownLinkContainer aka something like [text](url title)

If you wanna laugh this is how it looks right now /!\?\%(\\\)\@<!\[\%(\%([^\[\]]\|\\\[\|\\\]\)*\|\%([^\[\]]\|\\\[\|\\\]\)*\[\%([^\[\]]\|\\\[\|\\\]\)*\]\%([^\[\]]\|\\\[\|\\\]\)*\)\%(\n\%(\n\)\@!\%(\%([^\[\]]\|\\\[\|\\\]\)*\|\%([^\[\]]\|\\\[\|\\\]\)*\[\%([^\[\]]\|\\\[\|\\\]\)*\]\%([^\[\]]\|\\\[\|\\\]\)*\)\)*\]\%(\s*\|\n\%\(\n\)\@!\)\%(\%(\\\)\@<!(\%([^()]*\|[^()]*([^()]*)[^()]*\)\%(\n\%(\n\)\@!\%([^()]*\|[^()]*([^()]*)[^()]*\)\)*)\|\%(\\\)\@<!\[\%(\%([^\[\]]\|\\\[\|\\\]\)*\|\%([^\[\]]\|\\\[\|\\\]\)*\[\%([^\[\]]\|\\\[\|\\\]\)*\]\%([^\[\]]\|\\\[\|\\\]\)*\)\%(\n\%(\n\)\@!\%(\%([^\[\]]\|\\\[\|\\\]\)*\|\%([^\[\]]\|\\\[\|\\\]\)*\[\%([^\[\]]\|\\\[\|\\\]\)*\]\%([^\[\]]\|\\\[\|\\\]\)*\)\)*\]\)/

I did my best to avoid too much backtracking I think I did it, with things like this it doesn’t break a sweat but let me know you still have problems

Link with long long text