mirror of
https://github.com/neovim/neovim.git
synced 2026-07-15 22:00:40 +00:00
feat(api): rename buffer to buf in retval #38900
In3a4a66017b,4d3a67cd62we renamed "buffer" to "buf" in dict parameters. This commit also renames such keys in dict return-values.
This commit is contained in:
@@ -626,7 +626,8 @@ describe('autocmd api', function()
|
||||
local aus = api.nvim_get_autocmds { event = 'InsertEnter', buf = 0 }
|
||||
eq({
|
||||
{
|
||||
buffer = 2,
|
||||
buf = 2,
|
||||
buffer = 2, -- deprecated
|
||||
buflocal = true,
|
||||
command = ':echo "2"',
|
||||
event = 'InsertEnter',
|
||||
@@ -638,7 +639,8 @@ describe('autocmd api', function()
|
||||
aus = api.nvim_get_autocmds { event = 'InsertEnter', buf = 1 }
|
||||
eq({
|
||||
{
|
||||
buffer = 1,
|
||||
buf = 1,
|
||||
buffer = 1, -- deprecated
|
||||
buflocal = true,
|
||||
command = ':echo "1"',
|
||||
event = 'InsertEnter',
|
||||
@@ -650,7 +652,8 @@ describe('autocmd api', function()
|
||||
aus = api.nvim_get_autocmds { event = 'InsertEnter', buf = { 1, 2 } }
|
||||
eq({
|
||||
{
|
||||
buffer = 1,
|
||||
buf = 1,
|
||||
buffer = 1, -- deprecated
|
||||
buflocal = true,
|
||||
command = ':echo "1"',
|
||||
event = 'InsertEnter',
|
||||
@@ -658,7 +661,8 @@ describe('autocmd api', function()
|
||||
pattern = '<buffer=1>',
|
||||
},
|
||||
{
|
||||
buffer = 2,
|
||||
buf = 2,
|
||||
buffer = 2, -- deprecated
|
||||
buflocal = true,
|
||||
command = ':echo "2"',
|
||||
event = 'InsertEnter',
|
||||
|
||||
@@ -48,7 +48,8 @@ describe('nvim_get_keymap', function()
|
||||
replace_keycodes = 0,
|
||||
sid = 0,
|
||||
scriptversion = 1,
|
||||
buffer = 0,
|
||||
buf = 0,
|
||||
buffer = 0, -- deprecated
|
||||
nowait = 0,
|
||||
mode = 'n',
|
||||
mode_bits = 0x01,
|
||||
@@ -63,12 +64,12 @@ describe('nvim_get_keymap', function()
|
||||
|
||||
it('returns list of all applicable mappings', function()
|
||||
command(foo_bar_string)
|
||||
-- Only one mapping available
|
||||
-- Should be the same as the dictionary we supplied earlier
|
||||
-- and the dictionary you would get from maparg
|
||||
-- since this is a global map, and not script local
|
||||
-- Only one mapping available. Should be the same as `foo_bar_map_table`, and maparg() result
|
||||
-- (plus "buf"), since this is a global map.
|
||||
eq({ foo_bar_map_table }, api.nvim_get_keymap('n'))
|
||||
eq({ fn.maparg('foo', 'n', false, true) }, api.nvim_get_keymap('n'))
|
||||
-- Add "buf" key to maparg() result.
|
||||
local maparg_rv = vim.tbl_deep_extend('force', fn.maparg('foo', 'n', false, true), { buf = 0 })
|
||||
eq({ maparg_rv }, api.nvim_get_keymap('n'))
|
||||
|
||||
-- Add another mapping
|
||||
command('nnoremap foo_longer bar_longer')
|
||||
@@ -107,7 +108,8 @@ describe('nvim_get_keymap', function()
|
||||
foolong_bar_map_table['rhs'] = 'bar_longer'
|
||||
|
||||
local buffer_table = shallowcopy(foo_bar_map_table)
|
||||
buffer_table['buffer'] = 1
|
||||
buffer_table['buf'] = 1
|
||||
buffer_table['buffer'] = 1 -- deprecated
|
||||
|
||||
command('nnoremap <buffer> foo bar')
|
||||
|
||||
@@ -120,7 +122,8 @@ describe('nvim_get_keymap', function()
|
||||
command('nnoremap foo bar')
|
||||
|
||||
local buffer_table = shallowcopy(foo_bar_map_table)
|
||||
buffer_table['buffer'] = 1
|
||||
buffer_table['buf'] = 1
|
||||
buffer_table['buffer'] = 1 -- deprecated
|
||||
|
||||
command('nnoremap <buffer> foo bar')
|
||||
|
||||
@@ -143,7 +146,8 @@ describe('nvim_get_keymap', function()
|
||||
command('nnoremap <buffer> foo bar')
|
||||
-- Final buffer will have buffer mappings
|
||||
local buffer_table = shallowcopy(foo_bar_map_table)
|
||||
buffer_table['buffer'] = final_buffer
|
||||
buffer_table['buf'] = final_buffer
|
||||
buffer_table['buffer'] = final_buffer -- deprecated
|
||||
eq({ buffer_table }, api.nvim_buf_get_keymap(final_buffer, 'n'))
|
||||
eq({ buffer_table }, api.nvim_buf_get_keymap(0, 'n'))
|
||||
|
||||
@@ -302,7 +306,7 @@ describe('nvim_get_keymap', function()
|
||||
eq(':let g:maparg_test_var = 1<CR>', api.nvim_get_keymap('n')[1]['rhs'])
|
||||
end)
|
||||
|
||||
it('works correctly despite various &cpo settings', function()
|
||||
it("works correctly despite 'cpoptions'", function()
|
||||
local cpo_table = {
|
||||
script = 0,
|
||||
silent = 0,
|
||||
@@ -310,7 +314,8 @@ describe('nvim_get_keymap', function()
|
||||
replace_keycodes = 0,
|
||||
sid = 0,
|
||||
scriptversion = 1,
|
||||
buffer = 0,
|
||||
buf = 0,
|
||||
buffer = 0, -- deprecated
|
||||
nowait = 0,
|
||||
abbr = 0,
|
||||
noremap = 1,
|
||||
@@ -383,7 +388,8 @@ describe('nvim_get_keymap', function()
|
||||
replace_keycodes = 0,
|
||||
sid = 0,
|
||||
scriptversion = 1,
|
||||
buffer = 0,
|
||||
buf = 0,
|
||||
buffer = 0, -- deprecated
|
||||
nowait = 0,
|
||||
noremap = 1,
|
||||
lnum = 0,
|
||||
@@ -431,7 +437,8 @@ describe('nvim_get_keymap', function()
|
||||
replace_keycodes = 0,
|
||||
sid = sid_lua,
|
||||
scriptversion = 1,
|
||||
buffer = 0,
|
||||
buf = 0,
|
||||
buffer = 0, -- deprecated
|
||||
nowait = 0,
|
||||
mode = 'n',
|
||||
mode_bits = 0x01,
|
||||
@@ -453,7 +460,8 @@ describe('nvim_get_keymap', function()
|
||||
replace_keycodes = 0,
|
||||
sid = sid_api_client,
|
||||
scriptversion = 1,
|
||||
buffer = 0,
|
||||
buf = 0,
|
||||
buffer = 0, -- deprecated
|
||||
nowait = 0,
|
||||
mode = 'n',
|
||||
mode_bits = 0x01,
|
||||
@@ -470,7 +478,8 @@ describe('nvim_get_keymap', function()
|
||||
|
||||
local mapargs_i = {
|
||||
abbr = 1,
|
||||
buffer = 0,
|
||||
buf = 0,
|
||||
buffer = 0, -- deprecated
|
||||
expr = 0,
|
||||
replace_keycodes = 0,
|
||||
lhs = 'foo',
|
||||
@@ -488,7 +497,8 @@ describe('nvim_get_keymap', function()
|
||||
}
|
||||
local mapargs_c = {
|
||||
abbr = 1,
|
||||
buffer = 1,
|
||||
buf = 1,
|
||||
buffer = 1, -- deprecated
|
||||
expr = 0,
|
||||
replace_keycodes = 0,
|
||||
lhs = 'foo',
|
||||
@@ -559,6 +569,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
||||
to_return.replace_keycodes = not opts.replace_keycodes and 0 or 1
|
||||
to_return.sid = not opts.sid and sid_api_client or opts.sid
|
||||
to_return.scriptversion = 1
|
||||
-- to_return.buf = not opts.buffer and 0 or opts.buffer
|
||||
to_return.buffer = not opts.buffer and 0 or opts.buffer
|
||||
to_return.lnum = not opts.lnum and 0 or opts.lnum
|
||||
to_return.desc = opts.desc
|
||||
|
||||
@@ -2863,7 +2863,8 @@ describe('API', function()
|
||||
id = id,
|
||||
argv = argv,
|
||||
mode = 'terminal',
|
||||
buffer = buffer,
|
||||
buf = buffer,
|
||||
buffer = buffer, -- deprecated
|
||||
pty = '?',
|
||||
exitcode = -1,
|
||||
}
|
||||
@@ -2883,7 +2884,8 @@ describe('API', function()
|
||||
neq(nil, string.match(info.pty, '^/dev/'))
|
||||
end
|
||||
eq({ info = info }, event)
|
||||
info.buffer = 1
|
||||
info.buf = 1
|
||||
info.buffer = 1 -- deprecated
|
||||
eq({ [1] = testinfo, [2] = stderr, [3] = info }, api.nvim_list_chans())
|
||||
eq(info, api.nvim_get_chan_info(3))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user