mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
commit
e21aef1e10
@ -665,11 +665,15 @@ function msgpack#eval(s, special_objs) abort
|
|||||||
call add(expr, ']}')
|
call add(expr, ']}')
|
||||||
let s = s[1:]
|
let s = s[1:]
|
||||||
elseif s[0] is# ''''
|
elseif s[0] is# ''''
|
||||||
let char = matchstr(s, '\m\C^''\zs.\ze''')
|
let char = matchstr(s, '\v\C^\''\zs%(\\\d+|.)\ze\''')
|
||||||
if empty(char)
|
if empty(char)
|
||||||
throw 'char-invalid:Invalid integer character literal format: ' . s
|
throw 'char-invalid:Invalid integer character literal format: ' . s
|
||||||
endif
|
endif
|
||||||
call add(expr, char2nr(char))
|
if char[0] is# '\'
|
||||||
|
call add(expr, +char[1:])
|
||||||
|
else
|
||||||
|
call add(expr, char2nr(char))
|
||||||
|
endif
|
||||||
let s = s[len(char) + 2:]
|
let s = s[len(char) + 2:]
|
||||||
else
|
else
|
||||||
throw 'unknown:Invalid non-space character: ' . s
|
throw 'unknown:Invalid non-space character: ' . s
|
||||||
|
@ -241,8 +241,6 @@ function s:shada_check_type(type, val) abort
|
|||||||
if msg isnot# 0
|
if msg isnot# 0
|
||||||
return msg
|
return msg
|
||||||
endif
|
endif
|
||||||
if a:val > 0 || a:val < 1
|
|
||||||
endif
|
|
||||||
return 0
|
return 0
|
||||||
elseif a:type is# 'binarray'
|
elseif a:type is# 'binarray'
|
||||||
if type isnot# 'array'
|
if type isnot# 'array'
|
||||||
@ -359,9 +357,14 @@ function s:shada_string(type, v) abort
|
|||||||
if (has_key(s:SHADA_ENUMS, a:type) && type(a:v) == type(0)
|
if (has_key(s:SHADA_ENUMS, a:type) && type(a:v) == type(0)
|
||||||
\&& has_key(s:SHADA_REV_ENUMS[a:type], a:v))
|
\&& has_key(s:SHADA_REV_ENUMS[a:type], a:v))
|
||||||
return s:SHADA_REV_ENUMS[a:type][a:v]
|
return s:SHADA_REV_ENUMS[a:type][a:v]
|
||||||
elseif (a:type is# 'intchar' && type(a:v) == type(0)
|
" Restricting a:v to be <= 127 is not necessary, but intchar constants are
|
||||||
\&& strtrans(nr2char(a:v)) is# nr2char(a:v))
|
" normally expected to be either ASCII printable characters or NUL.
|
||||||
return "'" . nr2char(a:v) . "'"
|
elseif a:type is# 'intchar' && type(a:v) == type(0) && a:v >= 0 && a:v <= 127
|
||||||
|
if a:v > 0 && strtrans(nr2char(a:v)) is# nr2char(a:v)
|
||||||
|
return "'" . nr2char(a:v) . "'"
|
||||||
|
else
|
||||||
|
return "'\\" . a:v . "'"
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
return msgpack#string(a:v)
|
return msgpack#string(a:v)
|
||||||
endif
|
endif
|
||||||
|
@ -128,6 +128,11 @@ msgpack#eval({string}, {dict}) *msgpack#eval()*
|
|||||||
always evaluated to |msgpack-special-dict| values, as well as
|
always evaluated to |msgpack-special-dict| values, as well as
|
||||||
hexadecimal digits. When evaluating maps order of keys is preserved.
|
hexadecimal digits. When evaluating maps order of keys is preserved.
|
||||||
|
|
||||||
|
Note that in addition to regular integer representations that may be
|
||||||
|
obtained using |msgpack#string()| msgpack#eval() also supports C-style
|
||||||
|
“character” integer constants like `'/'` (equivalent to
|
||||||
|
`char2nr('/')`: `47`). This also allows `'\0'` (number is decimal).
|
||||||
|
|
||||||
*msgpack#equal*
|
*msgpack#equal*
|
||||||
msgpack#equal({msgpack-value}, {msgpack-value}) *msgpack#equal()*
|
msgpack#equal({msgpack-value}, {msgpack-value}) *msgpack#equal()*
|
||||||
Returns 1 if given values are equal, 0 otherwise. When comparing
|
Returns 1 if given values are equal, 0 otherwise. When comparing
|
||||||
|
@ -652,6 +652,8 @@ describe('In autoload/msgpack.vim', function()
|
|||||||
|
|
||||||
eval_eq('integer', ('a'):byte(), '\'a\'')
|
eval_eq('integer', ('a'):byte(), '\'a\'')
|
||||||
eval_eq('integer', 0xAB, '\'«\'')
|
eval_eq('integer', 0xAB, '\'«\'')
|
||||||
|
eval_eq('integer', 0, '\'\\0\'')
|
||||||
|
eval_eq('integer', 10246567, '\'\\10246567\'')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('correctly loads constants', function()
|
it('correctly loads constants', function()
|
||||||
|
@ -609,6 +609,18 @@ describe('In autoload/shada.vim', function()
|
|||||||
'abc',
|
'abc',
|
||||||
-1,
|
-1,
|
||||||
]}] ]]):gsub('\n', ''))
|
]}] ]]):gsub('\n', ''))
|
||||||
|
-- Regression: NUL separator must be properly supported
|
||||||
|
sd2strings_eq({
|
||||||
|
'History entry with timestamp ' .. epoch .. ':',
|
||||||
|
' @ Description_ Value',
|
||||||
|
' - history type SEARCH',
|
||||||
|
' - contents ""',
|
||||||
|
' - separator \'\\0\'',
|
||||||
|
}, ([[ [{'type': 4, 'timestamp': 0, 'data': [
|
||||||
|
1,
|
||||||
|
'',
|
||||||
|
0x0
|
||||||
|
]}] ]]):gsub('\n', ''))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works with register items', function()
|
it('works with register items', function()
|
||||||
@ -837,7 +849,7 @@ describe('In autoload/shada.vim', function()
|
|||||||
sd2strings_eq({
|
sd2strings_eq({
|
||||||
'Global mark with timestamp ' .. epoch .. ':',
|
'Global mark with timestamp ' .. epoch .. ':',
|
||||||
' % Key Description Value',
|
' % Key Description Value',
|
||||||
' + n name 20',
|
' + n name \'\\20\'',
|
||||||
' + f file name "foo"',
|
' + f file name "foo"',
|
||||||
' # Value is negative',
|
' # Value is negative',
|
||||||
' + l line number -10',
|
' + l line number -10',
|
||||||
@ -852,7 +864,18 @@ describe('In autoload/shada.vim', function()
|
|||||||
sd2strings_eq({
|
sd2strings_eq({
|
||||||
'Global mark with timestamp ' .. epoch .. ':',
|
'Global mark with timestamp ' .. epoch .. ':',
|
||||||
' % Key Description Value',
|
' % Key Description Value',
|
||||||
' + n name 20',
|
' + n name 128',
|
||||||
|
' + f file name "foo"',
|
||||||
|
' + l line number 1',
|
||||||
|
' + c column 0',
|
||||||
|
}, ([[ [{'type': 7, 'timestamp': 0, 'data': {
|
||||||
|
'n': 128,
|
||||||
|
'f': 'foo',
|
||||||
|
}}] ]]):gsub('\n', ''))
|
||||||
|
sd2strings_eq({
|
||||||
|
'Global mark with timestamp ' .. epoch .. ':',
|
||||||
|
' % Key Description Value',
|
||||||
|
' + n name \'\\20\'',
|
||||||
' + f file name "foo"',
|
' + f file name "foo"',
|
||||||
' # Expected integer',
|
' # Expected integer',
|
||||||
' + l line number "FOO"',
|
' + l line number "FOO"',
|
||||||
@ -1123,7 +1146,7 @@ describe('In autoload/shada.vim', function()
|
|||||||
'Local mark with timestamp ' .. epoch .. ':',
|
'Local mark with timestamp ' .. epoch .. ':',
|
||||||
' % Key Description Value',
|
' % Key Description Value',
|
||||||
' + f file name "foo"',
|
' + f file name "foo"',
|
||||||
' + n name 20',
|
' + n name \'\\20\'',
|
||||||
' # Value is negative',
|
' # Value is negative',
|
||||||
' + l line number -10',
|
' + l line number -10',
|
||||||
' # Value is negative',
|
' # Value is negative',
|
||||||
@ -1138,7 +1161,7 @@ describe('In autoload/shada.vim', function()
|
|||||||
'Local mark with timestamp ' .. epoch .. ':',
|
'Local mark with timestamp ' .. epoch .. ':',
|
||||||
' % Key Description Value',
|
' % Key Description Value',
|
||||||
' + f file name "foo"',
|
' + f file name "foo"',
|
||||||
' + n name 20',
|
' + n name \'\\20\'',
|
||||||
' # Expected integer',
|
' # Expected integer',
|
||||||
' + l line number "FOO"',
|
' + l line number "FOO"',
|
||||||
' # Expected integer',
|
' # Expected integer',
|
||||||
@ -1932,13 +1955,13 @@ describe('In autoload/shada.vim', function()
|
|||||||
'Buffer list with timestamp ' .. epoch .. ':',
|
'Buffer list with timestamp ' .. epoch .. ':',
|
||||||
' % Key Description Value',
|
' % Key Description Value',
|
||||||
' # Expected binary string',
|
' # Expected binary string',
|
||||||
' + f file name 10',
|
' + f file name \'\\10\'',
|
||||||
' + l line number 1',
|
' + l line number 1',
|
||||||
' + c column 0',
|
' + c column 0',
|
||||||
'',
|
'',
|
||||||
' % Key Description Value',
|
' % Key Description Value',
|
||||||
' # Expected binary string',
|
' # Expected binary string',
|
||||||
' + f file name 20',
|
' + f file name \'\\20\'',
|
||||||
' + l line number 1',
|
' + l line number 1',
|
||||||
' + c column 0',
|
' + c column 0',
|
||||||
})
|
})
|
||||||
@ -1948,7 +1971,7 @@ describe('In autoload/shada.vim', function()
|
|||||||
'Buffer list with timestamp ' .. epoch .. ':',
|
'Buffer list with timestamp ' .. epoch .. ':',
|
||||||
' % Key Description Value',
|
' % Key Description Value',
|
||||||
' # Expected binary string',
|
' # Expected binary string',
|
||||||
' + f file name 10',
|
' + f file name \'\\10\'',
|
||||||
' + l line number 1',
|
' + l line number 1',
|
||||||
' + c column 0',
|
' + c column 0',
|
||||||
'',
|
'',
|
||||||
|
Loading…
Reference in New Issue
Block a user