lotabout / skim.vim

vim support for skim
132 stars 19 forks source link

Fix version number extraction and comparison #21

Closed wks closed 1 year ago

wks commented 1 year ago

The vim plugin recently started to break when using any command, such as :Rg, complaining that I "need to update fzf". I don't know if the output of sk --version changed recently and broke the code, but the regular expression '[0-9.]*' in the matchstr statement doesn't match the string "sk 0.10.2" which sk --version prints. The VIM documentation of match() says:

Note that a match at the start is preferred, thus when the pattern is using "*" (any number of matches) it tends to find zero matches at the start instead of a number of matches further down in the text.

So I changed * to \+.

It is also comparing version numbers as strings, which was OK when the major/minor/micro versions all had only one digit. I fixed that, too.

anthraxx commented 1 year ago

I've already opened a PR for the same problem set in #20. However, It differs a bit. Instead I'm treating all version components individually as numbers by converting them explicitly using str2nr which makes the code and conversion more explicit to read.

lotabout commented 1 year ago

close this in favor of #20