mirror of
https://github.com/neovim/neovim.git
synced 2026-07-14 05:10:36 +00:00
Merge #40688 from justinmk/fixci
This commit is contained in:
@@ -255,8 +255,8 @@ LUA
|
||||
terminal supports it.
|
||||
• |vim.net.request()| can specify custom headers by passing `opts.headers`.
|
||||
• |vim.net.request()| can now accept `method` param overload for multiple HTTP methods.
|
||||
• |writefile()| treats Lua strings as "blob", so it can be used to write
|
||||
binary data.
|
||||
• |writefile()| treats Lua and RPC strings as |Blob|, so it can be used to
|
||||
write binary data.
|
||||
• |vim.fs.dir()| with `opts.err=true`, reports errors. An inaccessible root
|
||||
dir yields a single (name, nil, err) item.
|
||||
• |vim.fs.find()| returns a list of errors as its second return value.
|
||||
|
||||
@@ -197,7 +197,8 @@ Object nvim_eval(String expr, Arena *arena, Error *err)
|
||||
/// @param self `self` dict, or NULL for non-dict functions
|
||||
/// @param[out] err Error details, if any
|
||||
/// @return Result of the function call
|
||||
static Object _call_function(String fn, Array args, dict_T *self, Arena *arena, Error *err)
|
||||
static Object _call_function(uint64_t channel_id, String fn, Array args, dict_T *self, Arena *arena,
|
||||
Error *err)
|
||||
{
|
||||
static int recursive = 0; // recursion depth
|
||||
Object rv = OBJECT_INIT;
|
||||
@@ -233,9 +234,11 @@ static Object _call_function(String fn, Array args, dict_T *self, Arena *arena,
|
||||
funcexe.fe_selfdict = self;
|
||||
|
||||
TRY_WRAP(err, {
|
||||
const sctx_T save_current_sctx = api_set_sctx(channel_id);
|
||||
// call_func() retval is deceptive, ignore it. Instead TRY_WRAP sets `msg_list` to capture
|
||||
// abort-causing non-exception errors.
|
||||
(void)call_func(fn.data, (int)fn.size, &rettv, (int)args.size, vim_args, &funcexe);
|
||||
current_sctx = save_current_sctx;
|
||||
});
|
||||
|
||||
if (!ERROR_SET(err)) {
|
||||
@@ -260,10 +263,10 @@ static Object _call_function(String fn, Array args, dict_T *self, Arena *arena,
|
||||
/// @param args Function arguments packed in an Array
|
||||
/// @param[out] err Error details, if any
|
||||
/// @return Result of the function call
|
||||
Object nvim_call_function(String fn, Array args, Arena *arena, Error *err)
|
||||
Object nvim_call_function(uint64_t channel_id, String fn, Array args, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(1)
|
||||
{
|
||||
return _call_function(fn, args, NULL, arena, err);
|
||||
return _call_function(channel_id, fn, args, NULL, arena, err);
|
||||
}
|
||||
|
||||
/// Calls a Vimscript |Dictionary-function| with the given arguments.
|
||||
@@ -275,7 +278,8 @@ Object nvim_call_function(String fn, Array args, Arena *arena, Error *err)
|
||||
/// @param args Function arguments packed in an Array
|
||||
/// @param[out] err Error details, if any
|
||||
/// @return Result of the function call
|
||||
Object nvim_call_dict_function(Object dict, String fn, Array args, Arena *arena, Error *err)
|
||||
Object nvim_call_dict_function(uint64_t channel_id, Object dict, String fn, Array args,
|
||||
Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(4)
|
||||
{
|
||||
Object rv = OBJECT_INIT;
|
||||
@@ -337,7 +341,7 @@ Object nvim_call_dict_function(Object dict, String fn, Array args, Arena *arena,
|
||||
goto end;
|
||||
});
|
||||
|
||||
rv = _call_function(fn, args, self_dict, arena, err);
|
||||
rv = _call_function(channel_id, fn, args, self_dict, arena, err);
|
||||
end:
|
||||
if (mustfree) {
|
||||
tv_clear(&rettv);
|
||||
|
||||
@@ -1794,8 +1794,10 @@ void f_writefile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
}
|
||||
});
|
||||
} else if (argvars[0].v_type != VAR_BLOB
|
||||
// Always treat Lua strings as "blob" data.
|
||||
&& !(argvars[0].v_type == VAR_STRING && script_is_lua(current_sctx.sc_sid))) {
|
||||
// Always treat Lua/RPC strings as "blob" data.
|
||||
&& !(argvars[0].v_type == VAR_STRING
|
||||
&& (script_is_lua(current_sctx.sc_sid)
|
||||
|| current_sctx.sc_sid == SID_API_CLIENT))) {
|
||||
semsg(_(e_invarg2), _("writefile() first argument must be a List or a Blob"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -160,20 +160,25 @@ describe('nvim.dir', function()
|
||||
eq('alpha.txt', api.nvim_get_current_line())
|
||||
end)
|
||||
|
||||
it('lets startup plugins replace the - mapping', function()
|
||||
local config_dir = fn.stdpath('config')
|
||||
local plugin_dir = vim.fs.joinpath(config_dir, 'plugin')
|
||||
fn.mkdir(plugin_dir, 'p')
|
||||
fn.writefile({
|
||||
[[if vim.fn.mapcheck('-', 'n') == '' and vim.fn.hasmapto('<Plug>(dirvish_up)', 'n') == 0 then]],
|
||||
[[ vim.keymap.set('n', '-', '<Plug>(dirvish_up)')]],
|
||||
[[end]],
|
||||
}, vim.fs.joinpath(plugin_dir, 'dirvish.lua'))
|
||||
it('startup plugins can replace the `-` mapping', function()
|
||||
local plugin_file = vim.fs.joinpath(vim.fn.stdpath('config'), 'plugin/dirvish.lua')
|
||||
vim.fs.mkdir(vim.fs.dirname(plugin_file), { parents = true })
|
||||
finally(function()
|
||||
os.remove(plugin_file) -- XXX: Remove file only, to avoid n.rmdir() hang on Windows.
|
||||
end)
|
||||
vim.fn.writefile(
|
||||
[[
|
||||
if vim.fn.mapcheck('-', 'n') == '' and vim.fn.hasmapto('<Plug>(dirvish_up)', 'n') == 0 then
|
||||
vim.keymap.set('n', '-', '<Plug>(dirvish_up)')
|
||||
end
|
||||
]],
|
||||
plugin_file
|
||||
)
|
||||
|
||||
n.clear({ args_rm = { '-u', '--cmd' } })
|
||||
|
||||
eq(1, fn.exists('g:loaded_nvim_dir_plugin')) -- Avoid false negatives.
|
||||
eq('<Plug>(dirvish_up)', fn.mapcheck('-', 'n'))
|
||||
n.rmdir(config_dir)
|
||||
end)
|
||||
|
||||
it('preserves alternate buffer when opening a parent directory', function()
|
||||
|
||||
@@ -107,11 +107,18 @@ describe('writefile()', function()
|
||||
eq('a\0', read_file(fname))
|
||||
end)
|
||||
|
||||
it('writes Lua (binary) strings to a file', function()
|
||||
it('writes Lua (binary) strings', function()
|
||||
eq(0, exec_lua([[return vim.fn.writefile('foo\0bar', ..., 'b')]], fname))
|
||||
eq('foo\0bar', read_file(fname))
|
||||
end)
|
||||
|
||||
it('writes RPC-API (binary) String', function()
|
||||
eq(0, api.nvim_call_function('writefile', { 'foobar', fname }))
|
||||
eq('foobar', read_file(fname))
|
||||
eq(0, api.nvim_call_function('writefile', { 'foo\0bar', fname }))
|
||||
eq('foo\0bar', read_file(fname))
|
||||
end)
|
||||
|
||||
it('shows correct file name when supplied numbers', function()
|
||||
api.nvim_set_current_dir(dname)
|
||||
eq(
|
||||
|
||||
Reference in New Issue
Block a user