mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
inccommand: Preview :sub commands only after the delimiter is present
Closes #5888
This commit is contained in:
parent
dcd77c64ef
commit
f2dff86493
@ -9674,9 +9674,20 @@ bool cmd_can_preview(char_u *cmd)
|
|||||||
if (*ea.cmd == '*') {
|
if (*ea.cmd == '*') {
|
||||||
ea.cmd = skipwhite(ea.cmd + 1);
|
ea.cmd = skipwhite(ea.cmd + 1);
|
||||||
}
|
}
|
||||||
find_command(&ea, NULL);
|
char_u *end = find_command(&ea, NULL);
|
||||||
|
|
||||||
return ea.cmdidx == CMD_substitute
|
switch (ea.cmdidx) {
|
||||||
|| ea.cmdidx == CMD_smagic
|
case CMD_substitute:
|
||||||
|| ea.cmdidx == CMD_snomagic;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ local function common_setup(screen, inccommand, text)
|
|||||||
[14] = {foreground = Screen.colors.White, background = Screen.colors.Red},
|
[14] = {foreground = Screen.colors.White, background = Screen.colors.Red},
|
||||||
[15] = {bold=true, foreground=Screen.colors.Blue},
|
[15] = {bold=true, foreground=Screen.colors.Blue},
|
||||||
[16] = {background=Screen.colors.Grey90}, -- cursorline
|
[16] = {background=Screen.colors.Grey90}, -- cursorline
|
||||||
|
vis = {background=Screen.colors.LightGrey}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -207,6 +208,42 @@ describe(":substitute, 'inccommand' preserves", function()
|
|||||||
end)
|
end)
|
||||||
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)
|
end)
|
||||||
|
|
||||||
describe(":substitute, 'inccommand' preserves undo", function()
|
describe(":substitute, 'inccommand' preserves undo", function()
|
||||||
|
Loading…
Reference in New Issue
Block a user