Formatter: Use pathshorten() instead of substitute()

The default formatter uses a hand-build regexp for shortening the path
in the tabline. However, since it uses the \w  regex atom, this won't
match e.g. cyrillic letters.

To fix this, use the builtin pathshorten() function which does handle
this case correctly. For a test, use e.g. 'D/Учёба/t.c'

closes #1737
This commit is contained in:
Christian Brabandt 2018-06-04 21:59:16 +02:00
parent 044a90ed55
commit 1bb1ce594a
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09

View File

@ -18,7 +18,9 @@ function! airline#extensions#tabline#formatters#default#format(bufnr, buffers)
let _ .= '[No Name]'
else
if s:fnamecollapse
let _ .= substitute(fnamemodify(name, fmod), '\v\w\zs.{-}\ze(\\|/)', '', 'g')
" Does not handle non-ascii characters like Cyrillic: 'D/Учёба/t.c'
"let _ .= substitute(fnamemodify(name, fmod), '\v\w\zs.{-}\ze(\\|/)', '', 'g')
let _ .= pathshorten(fnamemodify(name, fmod))
else
let _ .= fnamemodify(name, fmod)
endif