mirror of
https://github.com/neovim/neovim.git
synced 2025-12-17 20:05:38 +00:00
functests: Refactor redir_exec
This commit is contained in:
@@ -492,17 +492,6 @@ local exc_exec = function(cmd)
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
local function redir_exec(cmd)
|
|
||||||
nvim_command(([[
|
|
||||||
redir => g:__output
|
|
||||||
silent! execute "%s"
|
|
||||||
redir END
|
|
||||||
]]):format(cmd:gsub('\n', '\\n'):gsub('[\\"]', '\\%0')))
|
|
||||||
local ret = nvim_eval('get(g:, "__output", 0)')
|
|
||||||
nvim_command('unlet! g:__output')
|
|
||||||
return ret
|
|
||||||
end
|
|
||||||
|
|
||||||
local function create_callindex(func)
|
local function create_callindex(func)
|
||||||
local table = {}
|
local table = {}
|
||||||
setmetatable(table, {
|
setmetatable(table, {
|
||||||
@@ -562,6 +551,19 @@ local curbufmeths = create_callindex(curbuf)
|
|||||||
local curwinmeths = create_callindex(curwin)
|
local curwinmeths = create_callindex(curwin)
|
||||||
local curtabmeths = create_callindex(curtab)
|
local curtabmeths = create_callindex(curtab)
|
||||||
|
|
||||||
|
local function redir_exec(cmd)
|
||||||
|
meths.set_var('__redir_exec_cmd', cmd)
|
||||||
|
nvim_command([[
|
||||||
|
redir => g:__redir_exec_output
|
||||||
|
silent! execute g:__redir_exec_cmd
|
||||||
|
redir END
|
||||||
|
]])
|
||||||
|
local ret = meths.get_var('__redir_exec_output')
|
||||||
|
meths.del_var('__redir_exec_output')
|
||||||
|
meths.del_var('__redir_exec_cmd')
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
local function get_pathsep()
|
local function get_pathsep()
|
||||||
return funcs.fnamemodify('.', ':p'):sub(-1)
|
return funcs.fnamemodify('.', ':p'):sub(-1)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user