aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/patch.vim
blob: 614be46270b65cb9fa4e7ee956b721e97cde8be6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
" Wrapper to emulate the nicer has() syntax for simultaneous version and patch
" level checking that was introduced in v7.4.236 and fixed in v7.4.237.
"
" * <https://github.com/vim/vim/releases/tag/v7.4.236>
" * <https://github.com/vim/vim/releases/tag/v7.4.237>
"
function! patch#(version) abort

  " If we're new enough, we can just use the native has()
  if has('patch-7.4.237')
    return has('patch-'.a:version)
  endif

  " Otherwise, we need to start splitting and comparing numbers
  let [major, minor, patch] = split(a:version, '\.')

  " The v:version variable looks like e.g. 801 for v8.1
  let l:version = major * 100 + minor

  " If the version numbers are the same, return whether we have the patch;
  " otherwise, return whether the version
  "
  return v:version == l:version
        \ ? has('patch-'.patch)
        \ : v:version > l:version

endfunction