mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #5932 from jamessan/icm-fixes
inccommand: Ignore errors during preview and make cmd_can_preview stricter
This commit is contained in:
commit
50d0d89129
@ -6093,7 +6093,6 @@ void ex_substitute(exarg_T *eap)
|
||||
int save_w_p_cul = curwin->w_p_cul;
|
||||
int save_w_p_cuc = curwin->w_p_cuc;
|
||||
|
||||
emsg_off++; // No error messages during command preview.
|
||||
curbuf->b_p_ul = LONG_MAX; // make sure we can undo all changes
|
||||
curwin->w_p_cul = false; // Disable 'cursorline'
|
||||
curwin->w_p_cuc = false; // Disable 'cursorcolumn'
|
||||
@ -6120,6 +6119,5 @@ void ex_substitute(exarg_T *eap)
|
||||
restore_search_patterns();
|
||||
win_size_restore(&save_view);
|
||||
ga_clear(&save_view);
|
||||
emsg_off--;
|
||||
unblock_autocmds();
|
||||
}
|
||||
|
@ -9674,9 +9674,20 @@ bool cmd_can_preview(char_u *cmd)
|
||||
if (*ea.cmd == '*') {
|
||||
ea.cmd = skipwhite(ea.cmd + 1);
|
||||
}
|
||||
find_command(&ea, NULL);
|
||||
char_u *end = find_command(&ea, NULL);
|
||||
|
||||
return ea.cmdidx == CMD_substitute
|
||||
|| ea.cmdidx == CMD_smagic
|
||||
|| ea.cmdidx == CMD_snomagic;
|
||||
switch (ea.cmdidx) {
|
||||
case CMD_substitute:
|
||||
case CMD_smagic:
|
||||
case CMD_snomagic:
|
||||
// Only preview once the pattern delimiter has been typed
|
||||
if (*end && !ASCII_ISALNUM(*end)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1607,7 +1607,9 @@ static int command_line_changed(CommandLineState *s)
|
||||
// - Update the screen while the effects are in place.
|
||||
// - Immediately undo the effects.
|
||||
State |= CMDPREVIEW;
|
||||
emsg_silent++; // Block error reporting as the command may be incomplete
|
||||
do_cmdline(ccline.cmdbuff, NULL, NULL, DOCMD_KEEPLINE|DOCMD_NOWAIT);
|
||||
emsg_silent--; // Unblock error reporting
|
||||
|
||||
// Restore the window "view".
|
||||
curwin->w_cursor = s->old_cursor;
|
||||
|
@ -42,6 +42,7 @@ local function common_setup(screen, inccommand, text)
|
||||
[14] = {foreground = Screen.colors.White, background = Screen.colors.Red},
|
||||
[15] = {bold=true, foreground=Screen.colors.Blue},
|
||||
[16] = {background=Screen.colors.Grey90}, -- cursorline
|
||||
vis = {background=Screen.colors.LightGrey}
|
||||
})
|
||||
end
|
||||
|
||||
@ -207,6 +208,42 @@ describe(":substitute, 'inccommand' preserves", function()
|
||||
end)
|
||||
end
|
||||
|
||||
for _, case in pairs{"", "split", "nosplit"} do
|
||||
it("visual selection for non-previewable command (inccommand="..case..") #5888", function()
|
||||
local screen = Screen.new(30,10)
|
||||
common_setup(screen, case, default_text)
|
||||
feed('1G2V')
|
||||
|
||||
feed(':s')
|
||||
screen:expect([[
|
||||
{vis:Inc substitution on} |
|
||||
t{vis:wo lines} |
|
||||
|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
:'<,'>s^ |
|
||||
]])
|
||||
|
||||
feed('o')
|
||||
screen:expect([[
|
||||
{vis:Inc substitution on} |
|
||||
t{vis:wo lines} |
|
||||
|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
:'<,'>so^ |
|
||||
]])
|
||||
end)
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
describe(":substitute, 'inccommand' preserves undo", function()
|
||||
@ -1201,6 +1238,40 @@ describe(":substitute, 'inccommand' with a failing expression", function()
|
||||
end
|
||||
end)
|
||||
|
||||
it('in the range does not error #5912', function()
|
||||
for _, case in pairs(cases) do
|
||||
refresh(case)
|
||||
feed(':100s/')
|
||||
|
||||
screen:expect([[
|
||||
Inc substitution on |
|
||||
two lines |
|
||||
|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
:100s/^ |
|
||||
]])
|
||||
|
||||
feed('<enter>')
|
||||
screen:expect([[
|
||||
Inc substitution on |
|
||||
two lines |
|
||||
^ |
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{15:~ }|
|
||||
{14:E16: Invalid range} |
|
||||
]])
|
||||
end
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
describe("'inccommand' and :cnoremap", function()
|
||||
|
Loading…
Reference in New Issue
Block a user