mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 03:23:47 -05:00
Fix the fix for colons in basepath
Commit 84bc2d6 tried to handle basepath values where the path contained
colons (see #877). However the fix had two (!) bugs.
- It used strridx() to find the colon separating the diffbase and the
path; it should have used stridx() because the base comes first.
- It used substring indexes incorrectly: foo[0:-1] returns the whole of
foo, not an empty string (:help exr-[:]).
Closes #878.
This commit is contained in:
@@ -252,8 +252,14 @@ function! gitgutter#utility#base_path(bufnr)
|
||||
" If we already know the original path at this diff base, return it.
|
||||
let basepath = gitgutter#utility#getbufvar(a:bufnr, 'basepath', '')
|
||||
if !empty(basepath)
|
||||
let i = strridx(basepath, ':')
|
||||
let [base, bpath] = [basepath[0:i-1], basepath[i+1:]]
|
||||
" basepath is diffbase:path
|
||||
" Note that path can also contain colons.
|
||||
" List destructuring / unpacking where the remaining items are assigned
|
||||
" to a single variable (:help let-unpack) is only available in v8.2.0540.
|
||||
let parts = split(basepath, ':', 1)
|
||||
let base = parts[0]
|
||||
let bpath = join(parts[1:], ':')
|
||||
|
||||
if base == diffbase
|
||||
return gitgutter#utility#shellescape(bpath)
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user