mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-12-07 20:54:26 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user