mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 23:31:51 +00:00
vim-patch:8.1.0291: 'incsearch' highlighting not used for :sort
Problem: 'incsearch' highlighting not used for :sort.
Solution: Handle pattern in :sort command.
81f56536b1
This commit is contained in:
@@ -314,6 +314,7 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s,
|
||||
&& (STRNCMP(cmd, "substitute", p - cmd) == 0
|
||||
|| STRNCMP(cmd, "smagic", p - cmd) == 0
|
||||
|| STRNCMP(cmd, "snomagic", MAX(p - cmd, 3)) == 0
|
||||
|| STRNCMP(cmd, "sort", p - cmd) == 0
|
||||
|| STRNCMP(cmd, "global", p - cmd) == 0
|
||||
|| STRNCMP(cmd, "vglobal", p - cmd) == 0)) {
|
||||
if (*cmd == 's' && cmd[1] == 'm') {
|
||||
@@ -330,6 +331,17 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// For ":sort" skip over flags.
|
||||
if (cmd[0] == 's' && cmd[1] == 'o') {
|
||||
while (ASCII_ISALPHA(*(p = skipwhite(p)))) {
|
||||
++p;
|
||||
}
|
||||
if (*p == NUL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
p = skipwhite(p);
|
||||
delim = *p++;
|
||||
end = skip_regexp(p, delim, p_magic, NULL);
|
||||
@@ -352,7 +364,7 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s,
|
||||
search_first_line = ea.line1;
|
||||
search_last_line = ea.line2;
|
||||
}
|
||||
} else if (*cmd == 's') {
|
||||
} else if (cmd[0] == 's' && cmd[1] != 'o') {
|
||||
// :s defaults to the current line
|
||||
search_first_line = curwin->w_cursor.lnum;
|
||||
search_last_line = curwin->w_cursor.lnum;
|
||||
|
@@ -692,6 +692,33 @@ func Test_incsearch_substitute_dump()
|
||||
call delete('Xis_subst_script')
|
||||
endfunc
|
||||
|
||||
" Similar to Test_incsearch_substitute_dump() for :sort
|
||||
func Test_incsearch_ssort_dump()
|
||||
if !exists('+incsearch')
|
||||
return
|
||||
endif
|
||||
if !CanRunVimInTerminal()
|
||||
throw 'Skipped: cannot make screendumps'
|
||||
endif
|
||||
call writefile([
|
||||
\ 'set incsearch hlsearch scrolloff=0',
|
||||
\ 'call setline(1, ["another one 2", "that one 3", "the one 1"])',
|
||||
\ ], 'Xis_sort_script')
|
||||
let buf = RunVimInTerminal('-S Xis_sort_script', {'rows': 9, 'cols': 70})
|
||||
" Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
|
||||
" the 'ambiwidth' check.
|
||||
sleep 100m
|
||||
|
||||
" Need to send one key at a time to force a redraw.
|
||||
call term_sendkeys(buf, ':sort ni u /on')
|
||||
sleep 100m
|
||||
call VerifyScreenDump(buf, 'Test_incsearch_sort_01', {})
|
||||
call term_sendkeys(buf, "\<Esc>")
|
||||
|
||||
call StopVimInTerminal(buf)
|
||||
call delete('Xis_sort_script')
|
||||
endfunc
|
||||
|
||||
func Test_incsearch_with_change()
|
||||
if !has('timers') || !exists('+incsearch') || !CanRunVimInTerminal()
|
||||
throw 'Skipped: cannot make screendumps and/or timers feature and/or incsearch option missing'
|
||||
|
@@ -21,6 +21,7 @@ describe('search cmdline', function()
|
||||
err = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
|
||||
more = { bold = true, foreground = Screen.colors.SeaGreen4 },
|
||||
tilde = { bold = true, foreground = Screen.colors.Blue1 },
|
||||
hl = { background = Screen.colors.Yellow },
|
||||
})
|
||||
end)
|
||||
|
||||
@@ -570,4 +571,20 @@ describe('search cmdline', function()
|
||||
?the |
|
||||
]])
|
||||
end)
|
||||
|
||||
it('incsearch works with :sort', function()
|
||||
-- oldtest: Test_incsearch_sort_dump().
|
||||
screen:try_resize(20, 4)
|
||||
command('set incsearch hlsearch scrolloff=0')
|
||||
funcs.setline(1, {'another one 2', 'that one 3', 'the one 1'})
|
||||
|
||||
feed(':sort ni u /on')
|
||||
screen:expect([[
|
||||
another {inc:on}e 2 |
|
||||
that {hl:on}e 3 |
|
||||
the {hl:on}e 1 |
|
||||
:sort ni u /on^ |
|
||||
]])
|
||||
feed('<esc>')
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user