New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect whitespace in status line #3898
Comments
Best regards, |
Actually, it some kind of fresh version :-) I downloaded it January 30. It seems that Windows binary is a bit outdated. Best regards you too :-) |
I think this is a duplicate of #1431 |
It seems that statusline doesn't properly work with whitespace.
Here is my .vimrc:
```vim
set encoding=utf-8
set guifont=Consolas:h10
colorscheme desert
let separator = ' '
set laststatus=2
set statusline=
set statusline+=%n
set statusline+=%{separator}
set statusline+=%t
set statusline+=%=
set statusline+=%(%l:%c%V%)
set statusline+=%{separator}
set statusline+=%{&expandtab?'spaces':'tab\ size'}:\ %{shiftwidth()}
set statusline+=%{separator}
set statusline+=%{&fileformat}
set statusline+=%{separator}
set statusline+=%{(strlen(&fileencoding)?&fileencoding:&encoding).((exists('+bomb')&&&bomb)?'-with-bom':'')}
set statusline+=%{separator}
set statusline+=%{strlen(&filetype)?&filetype:'text'}
```
And here is how Vim looks:
![statusline_bug](https://user-images.githubusercontent.com/18004961/52170281-a1ff9e00-2758-11e9-8772-6f14cd15aef5.png)
As you can see, at some places there are only 3 spaces instead of 4. and looks like a bug for me.
Then, if we use hard-coded spaces instead of `separator` - everything will be correct:
```vim
set encoding=utf-8
set guifont=Consolas:h10
colorscheme desert
set laststatus=2
set statusline=
set statusline+=%n\ \ \ \ "
set statusline+=%t
set statusline+=%=
set statusline+=%(%l:%c%V%)\ \ \ \ "
set statusline+=%{&expandtab?'spaces':'tab\ size'}:\ %{shiftwidth()}\ \ \ \ "
set statusline+=%{&fileformat}\ \ \ \ "
set statusline+=%{(strlen(&fileencoding)?&fileencoding:&encoding).((exists('+bomb')&&&bomb)?'-with-bom':'')}\ \ \ \ "
set statusline+=%{strlen(&filetype)?&filetype:'text'}
```
I hesitate to change how 'statusline' deals with whitespace especially
for %{} items. There are some tricks to drop whitespace, especially if
one of the items is empty. Existing implementations depend on that.
A better solution would be to explicitly have an item that specifies the
amount of white space, which then would be inserted literally.
…--
ARTHUR: Charge!
[They all charge with swords drawn towards the RABBIT. A tremendous twenty
second fight with Peckinpahish shots and borrowing heavily also on the
Kung Fu and karate-type films ensues, in which some four KNIGHTS are
comprehensively killed.]
ARTHUR: Run away! Run away!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
In other words, it's some kind of bug, which is considered as feature?
Interesting. As n00b, I don't know the way how it should be done, but // There are at least 2 Monty Python fans here! |
What if we allow --- a/src/buffer.c
+++ b/src/buffer.c
@@ -4223,7 +4223,7 @@ build_stl_str_hl(
break;
case STL_VIM_EXPR: /* '{' */
- itemisflag = TRUE;
+ itemisflag = zeropad ? FALSE : TRUE;
t = p;
while (*s != '}' && *s != NUL && p + 1 < out + outlen)
*p++ = *s++; |
Although, the other behavior of |
Does it exist a better workaround then using " This line is used as separator:
set statusline+=\ \ \ \ " |
I have the same problem, is there any news? Thanks |
It seems that statusline doesn't properly work with whitespace.
Here is my .vimrc:
And here is how Vim looks:
As you can see, at some places there are only 3 spaces instead of 4. and it looks like a bug for me.
Then, if we use hard-coded spaces instead of
separator
- everything will be correct:The text was updated successfully, but these errors were encountered: