mzlogin / vim-markdown-toc

A vim 7.4+ plugin to generate table of contents for Markdown files.
http://www.vim.org/scripts/script.php?script_id=5460
MIT License
613 stars 59 forks source link

Invalid range error #19

Closed dvcrn closed 7 years ago

dvcrn commented 7 years ago

I'm not sure if I did something wrong, but every time I try to generate the TOC or run :UpdateToc, I am getting this error:

2016-11-21 0 21 02

The TOC is still getting generated correctly, just this error appears. I am using silent! now to ignore the error. Any thoughts?

mzlogin commented 7 years ago

Thanks for reporting.

I can't reproduct this error in lastest version of Vim or NeoVim. Would you please provide me your NeoVim version and one demo file with this error appears? Thanks a lot!

BTW: It seems that error may appears in some versions of Vim/NeoVim sometimes, see https://github.com/neovim/neovim/issues/2600

dvcrn commented 7 years ago

I'm using NVIM 0.2.0-dev.

Minimal markdown:

<!-- vim-markdown-toc GFM -->
* [Tests](#tests)
  * [Another Tests](#another-tests)

<!-- vim-markdown-toc -->
# Tests
## Another Tests

Using :UpdateToc results in 2 range errors, one for each headline

mzlogin commented 7 years ago

I've checked over your dotfiles, and do some test with it, finally found that it caused by set re=1 in https://github.com/dvcrn/dotfiles/blob/master/vim/style.vim#L27. The following line in my code does not compatible with old regexp engine.

let l:headingLink = substitute(l:headingLink, "[^[:alnum:]\u4e00-\u9fbf _-]", "", "g")

Seems old regexp engine cannot handle range \u4e00-\u9fbf, so I changed my code to let this substitute force automatic selection regexp engine. It works on my nvim 0.2.0-dev under Ubuntu with your dotfiles.

Please update the plugin and try again, feedbacks are welcome.

BTW: What makes you to set re=1? The new regexp engine would provide better performance in most cases. I think keep default configuration for this is good enough. For more details by command :h regexpengine and :h two-engines.

dvcrn commented 7 years ago

Oh that was fast, thank you! Going through my dotfiles is definitely not something every project maintainer would do!

I am setting set re=1 because of what the comment above it says:

" trial & error. These 3 lines seem to cause most of the performance problems I
" was experiencing. Adding these here reduces most of that rendering lag.

I was experiencing very annoying rendering lag and adding these 3 lines seemed to get rid of it. Since then I just left the settings in my config and didn't touch them

mzlogin commented 7 years ago

You are welcome! Hope your problem is resolved.