mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
feat(:source, nvim_exec): defer script item creation until s:var access
For anonymous scripts, defer the creation of script items until an attempt to access a script-local variable is made. This dramatically reduces the number of script items created when using lots of vim.cmd and nvim_exec especially. This will mean <SID> usage fails until a script-local variable access is first made.
This commit is contained in:
@@ -26,13 +26,17 @@ describe(':source', function()
|
||||
\ k: "v"
|
||||
"\ (o_o)
|
||||
\ }
|
||||
let c = expand("<SID>")->empty()
|
||||
let s:s = 0zbeef.cafe
|
||||
let c = s:s]])
|
||||
let d = s:s]])
|
||||
|
||||
command('source')
|
||||
eq('2', meths.exec('echo a', true))
|
||||
eq("{'k': 'v'}", meths.exec('echo b', true))
|
||||
eq("0zBEEFCAFE", meths.exec('echo c', true))
|
||||
|
||||
-- Script items are created only on script var access
|
||||
eq("1", meths.exec('echo c', true))
|
||||
eq("0zBEEFCAFE", meths.exec('echo d', true))
|
||||
|
||||
exec('set cpoptions+=C')
|
||||
eq('Vim(let):E15: Invalid expression: #{', exc_exec('source'))
|
||||
@@ -62,7 +66,7 @@ describe(':source', function()
|
||||
feed_command(':source')
|
||||
eq('4', meths.exec('echo a', true))
|
||||
eq("{'K': 'V'}", meths.exec('echo b', true))
|
||||
eq("<SNR>3_C()", meths.exec('echo D()', true))
|
||||
eq("<SNR>1_C()", meths.exec('echo D()', true))
|
||||
|
||||
-- Source last line only
|
||||
feed_command(':$source')
|
||||
|
||||
Reference in New Issue
Block a user