Vimwiki: <Enter> create link bug with Chinese characters

Created on 6 Apr 2020  Â·  3Comments  Â·  Source: vimwiki/vimwiki

neovim-qt, windows10
syntax: markdown
Branch: dev
Revision: 78a41b7
Date: 2020-04-03 13:31:36 -0600


original text:

ä½ 
你好
你们好
你们好啊
你们好啊啊
你们好啊aaaaa
aaaaa你们好啊

press <Enter> on each word:

[ä½ ](ä½ .md)
[你好](你好.md)
[你们好](你们好.md)
[](你们好啊.md)
[](你们好啊啊.md)
[你们好啊aaaaa](你们好啊aaaaa.md)
[aaaaa你们好啊](aaaaa你们好啊.md)

As you can see, pure four or more Chinese characters have missing front part.

bug good first issue

All 3 comments

Fixed: d94b966c4626c6

__Short:__

let url_l = filter(url_l, 'v:val !~?  "^\\A\\{4,}$"')
" Becomes 
let url_l = filter(url_l, 'v:val !~?  "[!\"$%&''()*+,:;<=>?\[\]\\^`{}]"')

__Long:__

Pressing <Cr> (i.e. Enter) is calling the following code):

  1. vimwiki#base#follow_link('nosplit', 0, 1)
  2. function! vimwiki#base#normalize_link(is_visual_mode)
  3. function! s:normalize_link_syntax_n() abort
  4. function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) abort
  5. let descr = s:clean_url(url)
  6. let url_l = filter(url_l, 'v:val !~? "^\\A\\{4,}$"')

But from :h /\A: \A non-alphabetic character: [^A-Za-z] */\A* So this removes MANY unicodes.
I replaced a white-list (keep only aphabetical) with a black list (remove annoying characters)

Thank you very much for the feed back. This will help many people with non-alphabetic links

PS: I close the issue to clear where dev must code. Feel free to reopen AND to make other issues (or better pull request) if you experience similar problems.

@tinmarino Thanks for your effort, looking forward to your merge.

@BSDxxxx : it is already in the dev branch.
git fetch
git checkout origin dev

Edit: it is now in the dev branch : I did not realized I pushed in my personal repo.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mblarsen picture mblarsen  Â·  5Comments

Ram-Z picture Ram-Z  Â·  4Comments

lsrdg picture lsrdg  Â·  5Comments

yangkev picture yangkev  Â·  5Comments

imbilltucker picture imbilltucker  Â·  5Comments