aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-01-08 13:13:43 +0100
committerGitHub <noreply@github.com>2022-01-08 13:13:43 +0100
commit3088ac71f9fb7eb409a24aac6b2339e004658884 (patch)
tree95f8759005aefa771ab6f469d832a58998bc4ccd
parentb65a23a13a29176aa669afc5d1c906d1d51e0a39 (diff)
parent600e7e3b32345d71842b6b167359f4f72093e9b0 (diff)
downloadrneovim-3088ac71f9fb7eb409a24aac6b2339e004658884.tar.gz
rneovim-3088ac71f9fb7eb409a24aac6b2339e004658884.tar.bz2
rneovim-3088ac71f9fb7eb409a24aac6b2339e004658884.zip
Merge pull request #16991 from bk2204/ex-mode
Make mode() return correct value in ex mode
-rw-r--r--src/nvim/state.c2
-rw-r--r--test/functional/core/startup_spec.lua17
2 files changed, 18 insertions, 1 deletions
diff --git a/src/nvim/state.c b/src/nvim/state.c
index 68bc76660d..1fe8bb671d 100644
--- a/src/nvim/state.c
+++ b/src/nvim/state.c
@@ -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';
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index 4220d68ee1..ecec18346a 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -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' }))