Skip to content
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

'statusline' %{…} expressions will sometimes lose a leading space #28918

Open
scy opened this issue May 22, 2024 · 0 comments
Open

'statusline' %{…} expressions will sometimes lose a leading space #28918

scy opened this issue May 22, 2024 · 0 comments
Labels
bug-vim wrong behavior inherited from vim statusline tabline, winbar, statuscolumn
Milestone

Comments

@scy
Copy link

scy commented May 22, 2024

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
  • Insert some text to make sure the file is modified.
  • :set stl=%f%{&modified?'\ M':''}
  • The status line should say foo.txt M
  • :set stl=%{expand('%%')}%{&modified?'\ M':''}
  • The status line should now say foo.txtM, missing the space before the M.

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 case you're thinking that the %% in the first expression is the problem: :set stl=%{''}%{&modified?'\ M':''} has the status line only contain M, with no leading space either.
  • Using %F or %t as the first part will keep the space, while %r or %M will drop it.
  • Adding a second space in the second expression (%{&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

@scy scy added the bug issues reporting wrong behavior label May 22, 2024
@zeertzjq zeertzjq added bug-vim wrong behavior inherited from vim statusline tabline, winbar, statuscolumn and removed bug issues reporting wrong behavior labels May 22, 2024
@justinmk justinmk added this to the backlog milestone May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-vim wrong behavior inherited from vim statusline tabline, winbar, statuscolumn
Projects
None yet
Development

No branches or pull requests

3 participants