From e6d38c7dac2e079d9b0f1621fef193bca858664f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Nov 2023 11:46:20 +0800 Subject: vim-patch:9.0.2133: Cannot detect overstrike mode in Cmdline mode (#26263) Problem: Cannot detect overstrike mode in Cmdline mode Solution: Make mode() return "cr" for overstrike closes: vim/vim#13569 https://github.com/vim/vim/commit/d1c3ef1f47c87d1da056c56564e1985fe6f2931d --- test/functional/editor/mode_cmdline_spec.lua | 26 ++++++++++++++++++++++++++ test/old/testdir/test_functions.vim | 16 ++++++++++++++++ 2 files changed, 42 insertions(+) (limited to 'test') diff --git a/test/functional/editor/mode_cmdline_spec.lua b/test/functional/editor/mode_cmdline_spec.lua index fcd75ae3b6..d34b5a1a28 100644 --- a/test/functional/editor/mode_cmdline_spec.lua +++ b/test/functional/editor/mode_cmdline_spec.lua @@ -1,9 +1,11 @@ -- Cmdline-mode tests. local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') local clear, insert, funcs, eq, feed = helpers.clear, helpers.insert, helpers.funcs, helpers.eq, helpers.feed local eval = helpers.eval +local command = helpers.command local meths = helpers.meths describe('cmdline', function() @@ -43,6 +45,30 @@ describe('cmdline', function() eq('"', eval('@:')) end) + it('redraws statusline when toggling overstrike', function() + local screen = Screen.new(60, 4) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {reverse = true, bold = true}, -- StatusLine + }) + screen:attach() + command('set laststatus=2 statusline=%!mode(1)') + feed(':') + screen:expect{grid=[[ + | + {0:~ }| + {1:c }| + :^ | + ]]} + feed('') + screen:expect{grid=[[ + | + {0:~ }| + {1:cr }| + :^ | + ]]} + end) + describe('history', function() it('correctly clears start of the history', function() -- Regression test: check absence of the memory leak when clearing start of diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim index eae9c03335..fb1523e82a 100644 --- a/test/old/testdir/test_functions.vim +++ b/test/old/testdir/test_functions.vim @@ -798,8 +798,12 @@ func Test_mode() call feedkeys(":echo \=Save_mode()\\", 'xt') call assert_equal('c-c', g:current_modes) + call feedkeys(":\\=Save_mode()\",'xt') + call assert_equal("c-cr", g:current_modes) call feedkeys("gQecho \=Save_mode()\\vi\", 'xt') call assert_equal('c-cv', g:current_modes) + call feedkeys("gQ\\=Save_mode()\",'xt') + call assert_equal("c-cvr", g:current_modes) " call feedkeys("Qcall Save_mode()\vi\", 'xt') " call assert_equal('c-ce', g:current_modes) " How to test Ex mode? @@ -817,6 +821,18 @@ func Test_mode() call assert_equal('n-niR', g:current_modes) execute "normal! gR\g@l\" call assert_equal('n-niV', g:current_modes) + " Test statusline updates for overstike mode + if CanRunVimInTerminal() + let buf = RunVimInTerminal('', {'rows': 12}) + call term_sendkeys(buf, ":set laststatus=2 statusline=%!mode(1)\") + call term_sendkeys(buf, ":") + call TermWait(buf) + call VerifyScreenDump(buf, 'Test_mode_1', {}) + call term_sendkeys(buf, "\") + call TermWait(buf) + call VerifyScreenDump(buf, 'Test_mode_2', {}) + call StopVimInTerminal(buf) + endif if has('terminal') term -- cgit