Merge pull request #16991 from bk2204/ex-mode

Make mode() return correct value in ex mode
This commit is contained in:
bfredl 2022-01-08 13:13:43 +01:00 committed by GitHub
commit 3088ac71f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -180,7 +180,7 @@ char *get_mode(void)
buf[1] = 'x';
}
}
} else if (State & CMDLINE) {
} else if ((State & CMDLINE) || exmode_active) {
buf[0] = 'c';
if (exmode_active) {
buf[1] = 'v';

View File

@ -224,6 +224,23 @@ describe('startup', function()
end
end)
it('-e sets ex mode', function()
local screen = Screen.new(25, 3)
clear('-e')
screen:attach()
-- Verify we set the proper mode both before and after :vi.
feed("put =mode(1)<CR>vi<CR>:put =mode(1)<CR>")
screen:expect([[
cv |
^n |
:put =mode(1) |
]])
eq('cv\n',
funcs.system({nvim_prog, '-n', '-es' },
{ 'put =mode(1)', 'print', '' }))
end)
it('fails on --embed with -es/-Es', function()
matches('nvim[.exe]*: %-%-embed conflicts with %-es/%-Es',
funcs.system({nvim_prog, '--embed', '-es' }))