mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 23:31:51 +00:00
feat(shada): restore Blob globals properly
As Strings and Blobs are encoded as msgpack BINs, the current ShaDa implementation will restore global Blob variables as Strings (or msgpack special dicts if they contain NULs). Encode an additional element with Blob globals to differentiate them from Strings so that we can restore them with the correct type. Adjust variables_spec.lua's autotest() to also check for proper type.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
-- ShaDa variables saving/reading support
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local meths, funcs, nvim_command, eq =
|
||||
helpers.meths, helpers.funcs, helpers.command, helpers.eq
|
||||
local meths, funcs, nvim_command, eq, eval =
|
||||
helpers.meths, helpers.funcs, helpers.command, helpers.eq, helpers.eval
|
||||
|
||||
local shada_helpers = require('test.functional.shada.helpers')
|
||||
local reset, clear = shada_helpers.reset, shada_helpers.clear
|
||||
@@ -30,10 +30,12 @@ describe('ShaDa support code', function()
|
||||
else
|
||||
meths.set_var(varname, varval)
|
||||
end
|
||||
local vartype = eval('type(g:' .. varname .. ')')
|
||||
-- Exit during `reset` is not a regular exit: it does not write shada
|
||||
-- automatically
|
||||
nvim_command('qall')
|
||||
reset('set shada+=!')
|
||||
eq(vartype, eval('type(g:' .. varname .. ')'))
|
||||
eq(varval, meths.get_var(varname))
|
||||
end)
|
||||
end
|
||||
@@ -47,6 +49,8 @@ describe('ShaDa support code', function()
|
||||
autotest('false', 'FALSEVAR', false)
|
||||
autotest('null', 'NULLVAR', 'v:null', true)
|
||||
autotest('ext', 'EXTVAR', '{"_TYPE": v:msgpack_types.ext, "_VAL": [2, ["", ""]]}', true)
|
||||
autotest('blob', 'BLOBVAR', '0z12ab34cd', true)
|
||||
autotest('blob (with NULs)', 'BLOBVARNULS', '0z004e554c7300', true)
|
||||
|
||||
it('does not read back variables without `!` in &shada', function()
|
||||
meths.set_var('STRVAR', 'foo')
|
||||
|
Reference in New Issue
Block a user