aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2021-10-10 09:15:46 +0800
committerGitHub <noreply@github.com>2021-10-09 18:15:46 -0700
commitf4359b5dbdd5ed9aa230532382edd7eb6cd0a61b (patch)
tree60e8a3ff5d503517488510a6dd5600c12dc5b370 /src
parent65b8232260a1e95f53c6bf704dfa02cdd3125262 (diff)
downloadrneovim-f4359b5dbdd5ed9aa230532382edd7eb6cd0a61b.tar.gz
rneovim-f4359b5dbdd5ed9aa230532382edd7eb6cd0a61b.tar.bz2
rneovim-f4359b5dbdd5ed9aa230532382edd7eb6cd0a61b.zip
vim-patch:8.2.3461: distinguish Normal and Terminal-Normal mode #15878
Problem: Cannot distinguish Normal and Terminal-Normal mode. Solution: Make mode() return "nt" for Terminal-Normal mode. (issue vim/vim#8856) https://github.com/vim/vim/commit/72406a4bd2896915b6f541e26d41521a59b1f846
Diffstat (limited to 'src')
-rw-r--r--src/nvim/state.c2
-rw-r--r--src/nvim/testdir/test_functions.vim8
2 files changed, 10 insertions, 0 deletions
diff --git a/src/nvim/state.c b/src/nvim/state.c
index 04271d750c..4eb0073873 100644
--- a/src/nvim/state.c
+++ b/src/nvim/state.c
@@ -195,6 +195,8 @@ char *get_mode(void)
|| restart_edit == 'V') {
buf[1] = 'i';
buf[2] = (char)restart_edit;
+ } else if (curbuf->terminal) {
+ buf[1] = 't';
}
}
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index 366615821c..ed080afee6 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -710,6 +710,14 @@ func Test_mode()
call assert_equal('c-cv', g:current_modes)
" How to test Ex mode?
+ if has('terminal')
+ term
+ call feedkeys("\<C-W>N", 'xt')
+ call assert_equal('n', mode())
+ call assert_equal('nt', mode(1))
+ call feedkeys("aexit\<CR>", 'xt')
+ endif
+
bwipe!
iunmap <F2>
xunmap <F2>