mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.1.0890: %! item not allowed for 'rulerformat' (#31369)
Problem: %! item not allowed for 'rulerformat'
(yatinlala)
Solution: also allow to use %! for rulerformat option
(Yegappan Lakshmanan)
fixes: vim/vim#16091
closes: vim/vim#16118
ac023e8baa
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
parent
76dcc7029b
commit
5897994cb7
@ -5917,6 +5917,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
All fields except the {item} are optional. A single percent sign can
|
All fields except the {item} are optional. A single percent sign can
|
||||||
be given as "%%".
|
be given as "%%".
|
||||||
|
|
||||||
|
*stl-%!*
|
||||||
When the option starts with "%!" then it is used as an expression,
|
When the option starts with "%!" then it is used as an expression,
|
||||||
evaluated and the result is used as the option value. Example: >vim
|
evaluated and the result is used as the option value. Example: >vim
|
||||||
set statusline=%!MyStatusLine()
|
set statusline=%!MyStatusLine()
|
||||||
|
1
runtime/lua/vim/_meta/options.lua
generated
1
runtime/lua/vim/_meta/options.lua
generated
@ -6311,6 +6311,7 @@ vim.wo.stc = vim.wo.statuscolumn
|
|||||||
--- All fields except the {item} are optional. A single percent sign can
|
--- All fields except the {item} are optional. A single percent sign can
|
||||||
--- be given as "%%".
|
--- be given as "%%".
|
||||||
---
|
---
|
||||||
|
--- *stl-%!*
|
||||||
--- When the option starts with "%!" then it is used as an expression,
|
--- When the option starts with "%!" then it is used as an expression,
|
||||||
--- evaluated and the result is used as the option value. Example:
|
--- evaluated and the result is used as the option value. Example:
|
||||||
---
|
---
|
||||||
|
@ -8407,6 +8407,7 @@ return {
|
|||||||
All fields except the {item} are optional. A single percent sign can
|
All fields except the {item} are optional. A single percent sign can
|
||||||
be given as "%%".
|
be given as "%%".
|
||||||
|
|
||||||
|
*stl-%!*
|
||||||
When the option starts with "%!" then it is used as an expression,
|
When the option starts with "%!" then it is used as an expression,
|
||||||
evaluated and the result is used as the option value. Example: >vim
|
evaluated and the result is used as the option value. Example: >vim
|
||||||
set statusline=%!MyStatusLine()
|
set statusline=%!MyStatusLine()
|
||||||
|
@ -2191,8 +2191,12 @@ static const char *did_set_statustabline_rulerformat(optset_T *args, bool rulerf
|
|||||||
if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL) {
|
if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL) {
|
||||||
ru_wid = wid;
|
ru_wid = wid;
|
||||||
} else {
|
} else {
|
||||||
|
// Validate the flags in 'rulerformat' only if it doesn't point to
|
||||||
|
// a custom function ("%!" flag).
|
||||||
|
if ((*varp)[1] != '!') {
|
||||||
errmsg = check_stl_option(p_ruf);
|
errmsg = check_stl_option(p_ruf);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (rulerformat || s[0] != '%' || s[1] != '!') {
|
} else if (rulerformat || s[0] != '%' || s[1] != '!') {
|
||||||
// check 'statusline', 'winbar', 'tabline' or 'statuscolumn'
|
// check 'statusline', 'winbar', 'tabline' or 'statuscolumn'
|
||||||
// only if it doesn't start with "%!"
|
// only if it doesn't start with "%!"
|
||||||
|
@ -216,6 +216,22 @@ describe('cmdline', function()
|
|||||||
longish |
|
longish |
|
||||||
]]
|
]]
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- oldtest: Test_rulerformat_function()
|
||||||
|
it("'rulerformat' can use %!", function()
|
||||||
|
local screen = Screen.new(40, 2)
|
||||||
|
exec([[
|
||||||
|
func TestRulerFn()
|
||||||
|
return '10,20%=30%%'
|
||||||
|
endfunc
|
||||||
|
]])
|
||||||
|
api.nvim_set_option_value('ruler', true, {})
|
||||||
|
api.nvim_set_option_value('rulerformat', '%!TestRulerFn()', {})
|
||||||
|
screen:expect([[
|
||||||
|
^ |
|
||||||
|
10,20 30% |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('cmdwin', function()
|
describe('cmdwin', function()
|
||||||
|
@ -4036,6 +4036,27 @@ func Test_rulerformat_position()
|
|||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for using "%!" in 'rulerformat' to use a function
|
||||||
|
func Test_rulerformat_function()
|
||||||
|
CheckScreendump
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
func TestRulerFn()
|
||||||
|
return '10,20%=30%%'
|
||||||
|
endfunc
|
||||||
|
END
|
||||||
|
call writefile(lines, 'Xrulerformat_function', 'D')
|
||||||
|
|
||||||
|
let buf = RunVimInTerminal('-S Xrulerformat_function', #{rows: 2, cols: 40})
|
||||||
|
call term_sendkeys(buf, ":set ruler rulerformat=%!TestRulerFn()\<CR>")
|
||||||
|
call term_sendkeys(buf, ":redraw!\<CR>")
|
||||||
|
call term_wait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_rulerformat_function', {})
|
||||||
|
|
||||||
|
" clean up
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_getcompletion_usercmd()
|
func Test_getcompletion_usercmd()
|
||||||
command! -nargs=* -complete=command TestCompletion echo <q-args>
|
command! -nargs=* -complete=command TestCompletion echo <q-args>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user