mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 19:25:11 -07:00
Merge pull request #3365 from ZyX-I/refactor-string
Make `...` occurrences in echo output more useful
This commit is contained in:
commit
463b24a951
@ -7809,7 +7809,20 @@ This does NOT work: >
|
||||
postponed until you type something), force a redraw
|
||||
with the |:redraw| command. Example: >
|
||||
:new | redraw | echo "there is a new window"
|
||||
<
|
||||
< *:echo-self-refer*
|
||||
When printing nested containers echo prints second
|
||||
occurrence of the self-referencing container using
|
||||
"[...@level]" (self-referencing |List|) or
|
||||
"{...@level}" (self-referencing |Dict|): >
|
||||
:let l = []
|
||||
:call add(l, l)
|
||||
:let l2 = []
|
||||
:call add(l2, [l2])
|
||||
:echo l l2
|
||||
< echoes "[[...@0]] [[[...@0]]]". Echoing "[l]" will
|
||||
echo "[[[...@1]]]" because l first occurs at second
|
||||
level.
|
||||
|
||||
*:echon*
|
||||
:echon {expr1} .. Echoes each {expr1}, without anything added. Also see
|
||||
|:comment|.
|
||||
|
@ -75,6 +75,24 @@ are always available and may be used simultaneously in separate plugins. The
|
||||
|
||||
'encoding' cannot be changed after startup.
|
||||
|
||||
|string()| and |:echo| behaviour changed:
|
||||
1. No maximum recursion depth limit is applied to nested container
|
||||
structures.
|
||||
2. |string()| fails immediately on nested containers, not when recursion limit
|
||||
was exceeded.
|
||||
2. When |:echo| encounters duplicate containers like >
|
||||
|
||||
let l = []
|
||||
echo [l, l]
|
||||
<
|
||||
it does not use "[...]" (was: "[[], [...]]", now: "[[], []]"). "..." is
|
||||
only used for recursive containers.
|
||||
3. |:echo| printing nested containers adds "@level" after "..." designating
|
||||
the level at which recursive container was printed: |:echo-self-refer|.
|
||||
Same thing applies to |string()| (though it uses construct like
|
||||
"{E724@level}"), but this is not reliable because |string()| continues to
|
||||
error out.
|
||||
|
||||
==============================================================================
|
||||
4. New Features *nvim-features-new*
|
||||
|
||||
|
1391
src/nvim/eval.c
1391
src/nvim/eval.c
File diff suppressed because it is too large
Load Diff
@ -565,6 +565,18 @@ describe('msgpackdump() function', function()
|
||||
exc_exec('call msgpackdump([todump])'))
|
||||
end)
|
||||
|
||||
it('can dump dict with two same dicts inside', function()
|
||||
execute('let inter = {}')
|
||||
execute('let todump = {"a": inter, "b": inter}')
|
||||
eq({"\130\161a\128\161b\128"}, eval('msgpackdump([todump])'))
|
||||
end)
|
||||
|
||||
it('can dump list with two same lists inside', function()
|
||||
execute('let inter = []')
|
||||
execute('let todump = [inter, inter]')
|
||||
eq({"\146\144\144"}, eval('msgpackdump([todump])'))
|
||||
end)
|
||||
|
||||
it('fails to dump a recursive list in a special dict', function()
|
||||
execute('let todump = {"_TYPE": v:msgpack_types.array, "_VAL": []}')
|
||||
execute('call add(todump._VAL, todump)')
|
||||
|
@ -12,7 +12,8 @@ describe('storing global variables in viminfo files', function()
|
||||
end)
|
||||
|
||||
it('is working', function()
|
||||
local nvim2 = helpers.spawn({helpers.nvim_prog, '-u', 'NONE', '--embed'})
|
||||
local nvim2 = helpers.spawn({helpers.nvim_prog, '-u', 'NONE',
|
||||
'-i', 'Xviminfo', '--embed'})
|
||||
helpers.set_session(nvim2)
|
||||
|
||||
local test_dict = {foo = 1, bar = 0, longvarible = 1000}
|
||||
|
Loading…
Reference in New Issue
Block a user