Handle that the comment marker can contain regex

In the case of e.g. C Double-tap will correctly detect * as a potential
character a comment can start with. But * has special meaning in regular
expressions and in the case of Vim will trigger an error if not used
correctly.

Protect what Double-tap find by surrounding it in \V...\m. Thanks to
@utrack for the idea.

Fixes #5.
This commit is contained in:
Øystein Walle 2015-09-10 00:32:00 +02:00
parent 0ceb8558c3
commit 5b150bda13

View File

@ -53,7 +53,7 @@ function! s:Detect_empty_comment()
let s:commStart[&ft] = matchstr(&comments, s:pattern) let s:commStart[&ft] = matchstr(&comments, s:pattern)
endif endif
let line = getline('.') let line = getline('.')
if s:commStart[&ft] != '' && line =~ '^\s*'. s:commStart[&ft] . '\s*$' if s:commStart[&ft] != '' && line =~ '^\s*\V'. s:commStart[&ft] . '\m\s*$'
return "\<C-U>" return "\<C-U>"
else else
return "\<CR>" return "\<CR>"