From 7785f6aa6138cac0ec87ddc4e6f1a4b337b16d07 Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Sat, 21 Sep 2024 09:28:31 +0900 Subject: [PATCH] Fix a space inserted before first delimiter Partially revert the commit. https://github.com/godlygeek/tabular/commit/cdac1a607c Fixes #76 --- autoload/tabular.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autoload/tabular.vim b/autoload/tabular.vim index cbf3908..ec673c6 100644 --- a/autoload/tabular.vim +++ b/autoload/tabular.vim @@ -281,6 +281,8 @@ function! tabular#TabularizeStrings(strings, delim, ...) endfor endfor + let lead_blank = empty(filter(copy(lines), 'v:val[0] =~ "\\S"')) + " Concatenate the fields, according to the format pattern. for idx in range(len(lines)) let line = lines[idx] @@ -302,7 +304,7 @@ function! tabular#TabularizeStrings(strings, delim, ...) let field = s:Center(line[i], maxes[i]) endif - let line[i] = field . repeat(" ", pad) + let line[i] = field . (lead_blank && i == 0 ? '' : repeat(" ", pad)) endfor let prefix = common_indent