From f4359b5dbdd5ed9aa230532382edd7eb6cd0a61b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 10 Oct 2021 09:15:46 +0800 Subject: 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 --- src/nvim/state.c | 2 ++ src/nvim/testdir/test_functions.vim | 8 ++++++++ 2 files changed, 10 insertions(+) (limited to 'src') 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("\N", 'xt') + call assert_equal('n', mode()) + call assert_equal('nt', mode(1)) + call feedkeys("aexit\", 'xt') + endif + bwipe! iunmap xunmap -- cgit