mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
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
d1c3ef1f47
This commit is contained in:
2
runtime/doc/builtin.txt
generated
2
runtime/doc/builtin.txt
generated
@@ -4850,7 +4850,9 @@ mode([expr]) *mode()*
|
|||||||
Rvc Virtual Replace mode completion |compl-generic|
|
Rvc Virtual Replace mode completion |compl-generic|
|
||||||
Rvx Virtual Replace mode |i_CTRL-X| completion
|
Rvx Virtual Replace mode |i_CTRL-X| completion
|
||||||
c Command-line editing
|
c Command-line editing
|
||||||
|
cr Command-line while in overstrike mode |c_<Insert>|
|
||||||
cv Vim Ex mode |gQ|
|
cv Vim Ex mode |gQ|
|
||||||
|
cvr Vim Ex while in overstrike mode |c_<Insert>|
|
||||||
r Hit-enter prompt
|
r Hit-enter prompt
|
||||||
rm The -- more -- prompt
|
rm The -- more -- prompt
|
||||||
r? A |:confirm| query of some sort
|
r? A |:confirm| query of some sort
|
||||||
|
2
runtime/lua/vim/_meta/vimfn.lua
generated
2
runtime/lua/vim/_meta/vimfn.lua
generated
@@ -5812,7 +5812,9 @@ function vim.fn.mkdir(name, flags, prot) end
|
|||||||
--- Rvc Virtual Replace mode completion |compl-generic|
|
--- Rvc Virtual Replace mode completion |compl-generic|
|
||||||
--- Rvx Virtual Replace mode |i_CTRL-X| completion
|
--- Rvx Virtual Replace mode |i_CTRL-X| completion
|
||||||
--- c Command-line editing
|
--- c Command-line editing
|
||||||
|
--- cr Command-line while in overstrike mode |c_<Insert>|
|
||||||
--- cv Vim Ex mode |gQ|
|
--- cv Vim Ex mode |gQ|
|
||||||
|
--- cvr Vim Ex while in overstrike mode |c_<Insert>|
|
||||||
--- r Hit-enter prompt
|
--- r Hit-enter prompt
|
||||||
--- rm The -- more -- prompt
|
--- rm The -- more -- prompt
|
||||||
--- r? A |:confirm| query of some sort
|
--- r? A |:confirm| query of some sort
|
||||||
|
@@ -7038,7 +7038,9 @@ M.funcs = {
|
|||||||
Rvc Virtual Replace mode completion |compl-generic|
|
Rvc Virtual Replace mode completion |compl-generic|
|
||||||
Rvx Virtual Replace mode |i_CTRL-X| completion
|
Rvx Virtual Replace mode |i_CTRL-X| completion
|
||||||
c Command-line editing
|
c Command-line editing
|
||||||
|
cr Command-line while in overstrike mode |c_<Insert>|
|
||||||
cv Vim Ex mode |gQ|
|
cv Vim Ex mode |gQ|
|
||||||
|
cvr Vim Ex while in overstrike mode |c_<Insert>|
|
||||||
r Hit-enter prompt
|
r Hit-enter prompt
|
||||||
rm The -- more -- prompt
|
rm The -- more -- prompt
|
||||||
r? A |:confirm| query of some sort
|
r? A |:confirm| query of some sort
|
||||||
|
@@ -1835,8 +1835,10 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
case K_INS:
|
case K_INS:
|
||||||
case K_KINS:
|
case K_KINS:
|
||||||
ccline.overstrike = !ccline.overstrike;
|
ccline.overstrike = !ccline.overstrike;
|
||||||
|
|
||||||
ui_cursor_shape(); // may show different cursor shape
|
ui_cursor_shape(); // may show different cursor shape
|
||||||
|
may_trigger_modechanged();
|
||||||
|
status_redraw_curbuf();
|
||||||
|
redraw_statuslines();
|
||||||
return command_line_not_changed(s);
|
return command_line_not_changed(s);
|
||||||
|
|
||||||
case Ctrl_HAT:
|
case Ctrl_HAT:
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
#include "nvim/eval/typval.h"
|
#include "nvim/eval/typval.h"
|
||||||
#include "nvim/event/defs.h"
|
#include "nvim/event/defs.h"
|
||||||
#include "nvim/event/multiqueue.h"
|
#include "nvim/event/multiqueue.h"
|
||||||
|
#include "nvim/ex_getln.h"
|
||||||
#include "nvim/getchar.h"
|
#include "nvim/getchar.h"
|
||||||
#include "nvim/globals.h"
|
#include "nvim/globals.h"
|
||||||
#include "nvim/insexpand.h"
|
#include "nvim/insexpand.h"
|
||||||
@@ -210,6 +211,9 @@ void get_mode(char *buf)
|
|||||||
if (exmode_active) {
|
if (exmode_active) {
|
||||||
buf[i++] = 'v';
|
buf[i++] = 'v';
|
||||||
}
|
}
|
||||||
|
if ((State & MODE_CMDLINE) && cmdline_overstrike()) {
|
||||||
|
buf[i++] = 'r';
|
||||||
|
}
|
||||||
} else if (State & MODE_TERMINAL) {
|
} else if (State & MODE_TERMINAL) {
|
||||||
buf[i++] = 't';
|
buf[i++] = 't';
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
-- Cmdline-mode tests.
|
-- Cmdline-mode tests.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
|
local Screen = require('test.functional.ui.screen')
|
||||||
local clear, insert, funcs, eq, feed =
|
local clear, insert, funcs, eq, feed =
|
||||||
helpers.clear, helpers.insert, helpers.funcs, helpers.eq, helpers.feed
|
helpers.clear, helpers.insert, helpers.funcs, helpers.eq, helpers.feed
|
||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
|
local command = helpers.command
|
||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
|
|
||||||
describe('cmdline', function()
|
describe('cmdline', function()
|
||||||
@@ -43,6 +45,30 @@ describe('cmdline', function()
|
|||||||
eq('"<C-J><C-@><C-[><C-S-M><M-C-I><C-D-J>', eval('@:'))
|
eq('"<C-J><C-@><C-[><C-S-M><M-C-I><C-D-J>', eval('@:'))
|
||||||
end)
|
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('<Insert>')
|
||||||
|
screen:expect{grid=[[
|
||||||
|
|
|
||||||
|
{0:~ }|
|
||||||
|
{1:cr }|
|
||||||
|
:^ |
|
||||||
|
]]}
|
||||||
|
end)
|
||||||
|
|
||||||
describe('history', function()
|
describe('history', function()
|
||||||
it('correctly clears start of the history', function()
|
it('correctly clears start of the history', function()
|
||||||
-- Regression test: check absence of the memory leak when clearing start of
|
-- Regression test: check absence of the memory leak when clearing start of
|
||||||
|
@@ -798,8 +798,12 @@ func Test_mode()
|
|||||||
|
|
||||||
call feedkeys(":echo \<C-R>=Save_mode()\<C-U>\<CR>", 'xt')
|
call feedkeys(":echo \<C-R>=Save_mode()\<C-U>\<CR>", 'xt')
|
||||||
call assert_equal('c-c', g:current_modes)
|
call assert_equal('c-c', g:current_modes)
|
||||||
|
call feedkeys(":\<insert>\<C-r>=Save_mode()\<CR>",'xt')
|
||||||
|
call assert_equal("c-cr", g:current_modes)
|
||||||
call feedkeys("gQecho \<C-R>=Save_mode()\<CR>\<CR>vi\<CR>", 'xt')
|
call feedkeys("gQecho \<C-R>=Save_mode()\<CR>\<CR>vi\<CR>", 'xt')
|
||||||
call assert_equal('c-cv', g:current_modes)
|
call assert_equal('c-cv', g:current_modes)
|
||||||
|
call feedkeys("gQ\<insert>\<C-r>=Save_mode()\<CR>",'xt')
|
||||||
|
call assert_equal("c-cvr", g:current_modes)
|
||||||
" call feedkeys("Qcall Save_mode()\<CR>vi\<CR>", 'xt')
|
" call feedkeys("Qcall Save_mode()\<CR>vi\<CR>", 'xt')
|
||||||
" call assert_equal('c-ce', g:current_modes)
|
" call assert_equal('c-ce', g:current_modes)
|
||||||
" How to test Ex mode?
|
" How to test Ex mode?
|
||||||
@@ -817,6 +821,18 @@ func Test_mode()
|
|||||||
call assert_equal('n-niR', g:current_modes)
|
call assert_equal('n-niR', g:current_modes)
|
||||||
execute "normal! gR\<C-o>g@l\<Esc>"
|
execute "normal! gR\<C-o>g@l\<Esc>"
|
||||||
call assert_equal('n-niV', g:current_modes)
|
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)\<CR>")
|
||||||
|
call term_sendkeys(buf, ":")
|
||||||
|
call TermWait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_mode_1', {})
|
||||||
|
call term_sendkeys(buf, "\<insert>")
|
||||||
|
call TermWait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_mode_2', {})
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endif
|
||||||
|
|
||||||
if has('terminal')
|
if has('terminal')
|
||||||
term
|
term
|
||||||
|
Reference in New Issue
Block a user