gabrielelana / vim-markdown

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

Large comment block slow down #43

Open wsxarcher opened 8 years ago

wsxarcher commented 8 years ago

When you have a large comment block with scrolling around the file slows down.

cnelsonsic commented 8 years ago

I get similar issues with fenced code blocks:

echo "\n\`\`\`\n$(lorem --lines 5000)\n\`\`\`\n" > foo.md

Try to insert text at the end of the file in vim, (i and type some gibberish) it will take a loooong time to respond. If you ctrl+c after typing, your text will appear.

cnelsonsic commented 8 years ago

I stumbled across this SO answer which led me to the following output that is rather surprising:

  TOTAL      COUNT  MATCH   SLOWEST     AVERAGE   NAME               PATTERN
152.299062   47649  0       0.037333    0.003196  markdownXmlElement \c<\([-A-Z0-9_$?!:,.]\+\)[^>]\{-}>\_.\{-}<\/\1>
  1.830407   19575  2521    0.000683    0.000094  markdownUrlLinkInText \c\%(\W\)\@<=<\?\%(\%(\<\%(https\?\|ftp\|file\):\/\/\|www\.\|ftp\.\)\|\/\/\?\)\%(&#\?[0-9A-Za-z]\{1,8};\|\\\|([-A-Z0-9+&@#/%=~_|$?!:,.]*\\\
?)
  0.781830   47649  0       0.000336    0.000016  markdownLinkContainer !\?\%(\\\)\@<!\[\%(\%([^\[\]]\|\\\[\|\\\]\)*\|\%([^\[\]]\|\\\[\|\\\]\)*\[\%([^\[\]]\|\\\[\|\\\]\)*\]\%([^\[\]]\|\\\[\|\\\]\)*\)\%(\n\%(\n\)
\@
  0.476055   47649  472     0.000105    0.000010  markdownInlineCode \%(`\)\@<!`\z(`\+\)
  0.460541   42626  0       0.000122    0.000011  markdownCodeBlock  \%(^\n\)\@<=\%(\%(\s\{4,}\|\t\+\).*\n\)\+$
  0.454228   47955  409     0.000098    0.000009  markdownItalic     \%(\s\|_\|^\)\@<=\*\%(\s\|\*\|$\)\@!
  0.447476   47649  0       0.000106    0.000009  markdownItalic     \%(\s\|\*\|^\)\@<=_\%(\s\|_\|$\)\@!
  0.446627   47649  0       0.000347    0.000009  markdownStrike     \%(\\\)\@<!\~\~\%(\S\)\@=\_.\{-}\%(\S\)\@<=\~\~
  0.439527   47649  0       0.000099    0.000009  markdownBoldItalic \%(\s\|\*\|^\)\@<=__\*\%(\s\|\*\|$\)\@!
  0.438952   47649  0       0.000216    0.000009  markdownBoldItalic \%(\s\|\*\|^\)\@<=___\%(\s\|_\|$\)\@!
gabrielelana commented 8 years ago

@cnelsonsic Nice! Thanks, I will look into it tomorrow

gabrielelana commented 8 years ago

@cnelsonsic unfortunately I'm unable to reproduce it, what version of vim are you using?