'statusline'
%{…}
expressions will sometimes lose a leading space
#28918
Labels
Milestone
'statusline'
%{…}
expressions will sometimes lose a leading space
#28918
Problem
There seems to be some obscure, undocumented logic when displaying the status line that will remove a single space character in some situations.
Steps to reproduce
nvim --clean foo.txt
:set stl=%f%{&modified?'\ M':''}
foo.txt M
:set stl=%{expand('%%')}%{&modified?'\ M':''}
foo.txtM
, missing the space before theM
.Expected behavior
The leading space returned by the second expression should not be removed, and certainly not depending on what the first expression is.
Looking at vim/vim#3898, the Vim folks seem to be aware of this since 2017, but it looks to me as if they hesitate changing it, for xkcd 1172 reasons. I'm raising this here, maybe Neovim is willing to break backwards compatibility to make things more consistent.
%%
in the first expression is the problem::set stl=%{''}%{&modified?'\ M':''}
has the status line only containM
, with no leading space either.%F
or%t
as the first part will keep the space, while%r
or%M
will drop it.%{&modified?'\ \ M':''}
) will result in one being printed.Neovim version (nvim -v)
NVIM v0.10.0
Vim (not Nvim) behaves the same?
yes, VIM 9.0.1378 (including 1499)
Operating system/version
Debian 12 bookworm
Terminal name/version
kitty 0.26.5
$TERM environment variable
xterm-kitty
Installation
AppImage, but also occurs with Debian's 0.7.2
The text was updated successfully, but these errors were encountered: