From 1bb1ce594aa5b80fb331403f2e0683a77b6e79c4 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Mon, 4 Jun 2018 21:59:16 +0200 Subject: [PATCH] Formatter: Use pathshorten() instead of substitute() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- autoload/airline/extensions/tabline/formatters/default.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autoload/airline/extensions/tabline/formatters/default.vim b/autoload/airline/extensions/tabline/formatters/default.vim index faed20c1..c98d7ef8 100644 --- a/autoload/airline/extensions/tabline/formatters/default.vim +++ b/autoload/airline/extensions/tabline/formatters/default.vim @@ -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