vim-patch:9.2.0538: Cannot keep leading whitespace in %{} statusline expr (#40007)

Problem:  A leading space in the result of a %{} item is sometimes
          stripped, and an all-digit result is converted to a number.
Solution: Add %0{} atom which inserts the expression result verbatim
          (glepnir)

fixes:  vim/vim#3898
closes: vim/vim#20315

e8d7a40b98

Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
zeertzjq
2026-05-26 09:04:24 +08:00
committed by GitHub
parent 13b7319bae
commit d214c24129
6 changed files with 26 additions and 5 deletions

View File

@@ -6817,7 +6817,8 @@ vim.wo.stc = vim.wo.statuscolumn
--- { NF Evaluate expression between "%{" and "}" and substitute result.
--- Note that there is no "%" before the closing "}". The
--- expression cannot contain a "}" character, call a function to
--- work around that. See `stl-%{` below.
--- work around that. See `stl-%{` below. Use "%0{" to insert the
--- result verbatim.
--- `{%` - This is almost same as "{" except the result of the expression is
--- re-evaluated as a statusline format string. Thus if the
--- return value of expr contains "%" items they will get expanded.
@@ -6926,6 +6927,8 @@ vim.wo.stc = vim.wo.statuscolumn
--- A result of all digits is regarded a number for display purposes.
--- Otherwise the result is taken as flag text and applied to the rules
--- described above.
--- *stl-%0{*
--- With %0{ neither applies: the result is inserted as a literal string.
---
--- Watch out for errors in expressions. They may render Vim unusable!
--- If you are stuck, hold down ':' or 'Q' to get a prompt, then quit and