diff --git a/autoload/vimwiki/u.vim b/autoload/vimwiki/u.vim index 26e91cd..d2e3851 100644 --- a/autoload/vimwiki/u.vim +++ b/autoload/vimwiki/u.vim @@ -295,13 +295,19 @@ endfunction function! vimwiki#u#get_punctuation_string() abort " Faster " See: https://github.github.com/gfm/#ascii-punctuation-character - return '!"#$%&''()*+,-./:;<=>?@\[\\\]^`{}|~' + " res = '!"#$%&''()*+,-./:;<=>?@\[\\\]^`{}|~' + " But I removed the * as it is treated as a special case + return '!"#$%&''()+,-./:;<=>?@\[\\\]^`{}|~' endfunction function! vimwiki#u#hi_expand_regex(lst) abort " Helper: Expand regex from reduced typeface delimiters " :param: list> with reduced regex + " 1: Left delimiter + " 2: right delimiter + " 3: possible characters to ignore (default '$^' => never match) + " 4: can multiply delimiter (boolean) (default 0 => do not repeat) " Return: list with extended regex delimiters (not inside a word) " -- [['\*_', '_\*']] -> [['\*_\S\@=', '\S\@<=_\*\%(\s\|$\)\@=']] " Note: For purposes of this definition, the beginning and the end of the line count as Unicode whitespace. @@ -313,42 +319,46 @@ function! vimwiki#u#hi_expand_regex(lst) abort for a_delimiter in a:lst let r_left_del = a_delimiter[0] let r_right_del = a_delimiter[1] + let r_repeat_del = len(a_delimiter) >= 3 ? a_delimiter[2] : '$^' + let b_can_mult = len(a_delimiter) >= 4 ? a_delimiter[3] : 0 + + " Craft the repeatable middle + let r_mult = b_can_mult ? '\+' : '' + let r_left_repeat = '\%(\%(' . r_left_del . '\)' . r_mult . '\)' + let r_right_repeat = '\%(\%(' . r_right_del . '\)' . r_mult . '\)' + let r_unescaped_repeat = '\%(\\\|\\\@ 1 && a:delim[-2:-2] ==# '\') ? a:delim[-2:-1] : a:delim[-1:] - " Hardcode for markdown - let c_start = '[_*]' - let c_end = '[_*]' - - let rx_mult = a:b_can_mult ? '\+' : '' - - let rx_start = '\%(^\|\%(\\\@ output silent execute a:search_command redir END + + " The location list should not be empty Assert !empty(getloclist(0)), a:test_name.": no location list result" + + " The location list should contains entries Assert match(output, '\d of \d') > -1, a:test_name.": no result message" " Tests that VimwikiSearch is quoting the pattern correctly. @@ -30,7 +36,6 @@ Execute (Search test wiki): AssertEqual "= Test Wiki =", getline(1) AssertEqual "vimwiki", &filetype - call TestSearch('VimwikiSearch foo', 'pattern with no spaces') call TestSearch('VimwikiSearch foo bar', 'pattern with spaces') call TestSearch('VimwikiSearch foo\bar', 'pattern with ''\''') diff --git a/test/syntax.vader b/test/syntax.vader index c27181a..181f2b0 100644 --- a/test/syntax.vader +++ b/test/syntax.vader @@ -37,6 +37,7 @@ Given vimwiki (Markdown typeface with escape sequence #1044: _ __ * ** {{{2): a ~~staaill deleted~~ Del 9 $$Eq\$$ uation follows$ Math 10 `code \` not finished inline` Code 11 + 012345678901234567890 Execute (Set syntax markdown): call SetSyntax('markdown') @@ -48,7 +49,8 @@ Execute (Assert Syntax of escape typeface): AssertEqual 'VimwikiBold4' , SyntaxAt(4, 14) . 4 AssertEqual 'VimwikiItalic5' , SyntaxAt(5, 14) . 5 " See: #1303 where an escape start can close the region - AssertEqual '6' , SyntaxAt(6, 14) . 6 + " Fixed removing vars.vim::expand_delimiter + AssertEqual 'VimwikiItalic6' , SyntaxAt(6, 14) . 6 AssertEqual 'VimwikiSuperScript7', SyntaxAt(7, 14) . 7 AssertEqual 'VimwikiSubScript8' , SyntaxAt(8, 14) . 8 AssertEqual 'VimwikiDelText9' , SyntaxAt(9, 14) . 9 diff --git a/test/syntax_markdown_gfm_typeface.vader b/test/syntax_markdown_gfm_typeface.vader index 75cade9..33820f1 100644 --- a/test/syntax_markdown_gfm_typeface.vader +++ b/test/syntax_markdown_gfm_typeface.vader @@ -623,8 +623,8 @@ Execute (Set Markdown): Execute (Assert Syntax): CommentLine 'Empty emphasis' - AssertEqual '', SyntaxAt(1, 1) - AssertEqual '', SyntaxAt(2, 1) + AssertEqual '1', SyntaxAt(1, 1) . 1 + AssertEqual '2', SyntaxAt(2, 1) . 2 Given vimwiki (Typeface: https://github.github.com/gfm/#example-446):