feat(:restart): v:startreason #40186

Problem:
It's clumsy for scripts to handle a "restart", without custom mappings or
global vars.

Solution:
Introduce `v:startreason`

(cherry picked from commit ae426ee465)
This commit is contained in:
Nathan Zeng
2026-06-18 12:49:12 -07:00
committed by Olivia Kinnear
parent a4985ac902
commit 611b4f8237
12 changed files with 69 additions and 3 deletions

View File

@@ -48,3 +48,11 @@ describe('v:argf', function()
eq({ abs1, abs2, abs3 }, n.eval('v:argf'))
end)
end)
describe('v:startreason', function()
it('is read-only and starts as "normal"', function()
n.clear { args = { '--cmd', 'let g:early_startreason = v:startreason' } }
eq('normal', eval('g:early_startreason'))
t.matches('E46', t.pcall_err(command, "let v:startreason = 'restart'"))
end)
end)