mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 00:08:19 +00:00
vim-patch:8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Problem: Error while typing :/foo/s// with 'incsearch' enabled.
Solution: Do not give search errors when highlighting matches.
50eb16c3b2
This commit is contained in:
@@ -1371,7 +1371,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ea.cmd = cmd;
|
ea.cmd = cmd;
|
||||||
if (parse_cmd_address(&ea, &errormsg) == FAIL) {
|
if (parse_cmd_address(&ea, &errormsg, false) == FAIL) {
|
||||||
goto doend;
|
goto doend;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2229,7 +2229,7 @@ int parse_command_modifiers(exarg_T *eap, char_u **errormsg, bool skip_only)
|
|||||||
|
|
||||||
case 't': if (checkforcmd(&p, "tab", 3)) {
|
case 't': if (checkforcmd(&p, "tab", 3)) {
|
||||||
long tabnr = get_address(
|
long tabnr = get_address(
|
||||||
eap, &eap->cmd, ADDR_TABS, eap->skip, false, 1);
|
eap, &eap->cmd, ADDR_TABS, eap->skip, skip_only, false, 1);
|
||||||
|
|
||||||
if (tabnr == MAXLNUM) {
|
if (tabnr == MAXLNUM) {
|
||||||
cmdmod.tab = tabpage_index(curtab) + 1;
|
cmdmod.tab = tabpage_index(curtab) + 1;
|
||||||
@@ -2301,9 +2301,9 @@ static void free_cmdmod(void)
|
|||||||
|
|
||||||
|
|
||||||
// Parse the address range, if any, in "eap".
|
// Parse the address range, if any, in "eap".
|
||||||
// May set the last search pattern.
|
// May set the last search pattern, unless "silent" is true.
|
||||||
// Return FAIL and set "errormsg" or return OK.
|
// Return FAIL and set "errormsg" or return OK.
|
||||||
int parse_cmd_address(exarg_T *eap, char_u **errormsg)
|
int parse_cmd_address(exarg_T *eap, char_u **errormsg, bool silent)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
int address_count = 1;
|
int address_count = 1;
|
||||||
@@ -2341,7 +2341,7 @@ int parse_cmd_address(exarg_T *eap, char_u **errormsg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
eap->cmd = skipwhite(eap->cmd);
|
eap->cmd = skipwhite(eap->cmd);
|
||||||
lnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip,
|
lnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip, silent,
|
||||||
eap->addr_count == 0, address_count++);
|
eap->addr_count == 0, address_count++);
|
||||||
if (eap->cmd == NULL) { // error detected
|
if (eap->cmd == NULL) { // error detected
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -3695,6 +3695,7 @@ static linenr_T get_address(exarg_T *eap,
|
|||||||
char_u **ptr,
|
char_u **ptr,
|
||||||
int addr_type, // flag: one of ADDR_LINES, ...
|
int addr_type, // flag: one of ADDR_LINES, ...
|
||||||
int skip, // only skip the address, don't use it
|
int skip, // only skip the address, don't use it
|
||||||
|
bool silent, // no errors or side effects
|
||||||
int to_other_file, // flag: may jump to other file
|
int to_other_file, // flag: may jump to other file
|
||||||
int address_count) // 1 for first, >1 after comma
|
int address_count) // 1 for first, >1 after comma
|
||||||
{
|
{
|
||||||
@@ -3826,13 +3827,15 @@ static linenr_T get_address(exarg_T *eap,
|
|||||||
if (*cmd == c)
|
if (*cmd == c)
|
||||||
++cmd;
|
++cmd;
|
||||||
} else {
|
} else {
|
||||||
pos = curwin->w_cursor; /* save curwin->w_cursor */
|
int flags;
|
||||||
/*
|
|
||||||
* When '/' or '?' follows another address, start
|
pos = curwin->w_cursor; // save curwin->w_cursor
|
||||||
* from there.
|
|
||||||
*/
|
// When '/' or '?' follows another address, start from
|
||||||
if (lnum != MAXLNUM)
|
// there.
|
||||||
|
if (lnum != MAXLNUM) {
|
||||||
curwin->w_cursor.lnum = lnum;
|
curwin->w_cursor.lnum = lnum;
|
||||||
|
}
|
||||||
|
|
||||||
// Start a forward search at the end of the line (unless
|
// Start a forward search at the end of the line (unless
|
||||||
// before the first line).
|
// before the first line).
|
||||||
@@ -3846,7 +3849,8 @@ static linenr_T get_address(exarg_T *eap,
|
|||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
}
|
}
|
||||||
searchcmdlen = 0;
|
searchcmdlen = 0;
|
||||||
if (!do_search(NULL, c, cmd, 1L, SEARCH_HIS | SEARCH_MSG, NULL)) {
|
flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG;
|
||||||
|
if (!do_search(NULL, c, cmd, 1L, flags, NULL)) {
|
||||||
curwin->w_cursor = pos;
|
curwin->w_cursor = pos;
|
||||||
cmd = NULL;
|
cmd = NULL;
|
||||||
goto error;
|
goto error;
|
||||||
@@ -7751,7 +7755,7 @@ static void ex_put(exarg_T *eap)
|
|||||||
*/
|
*/
|
||||||
static void ex_copymove(exarg_T *eap)
|
static void ex_copymove(exarg_T *eap)
|
||||||
{
|
{
|
||||||
long n = get_address(eap, &eap->arg, eap->addr_type, false, false, 1);
|
long n = get_address(eap, &eap->arg, eap->addr_type, false, false, false, 1);
|
||||||
if (eap->arg == NULL) { // error detected
|
if (eap->arg == NULL) { // error detected
|
||||||
eap->nextcmd = NULL;
|
eap->nextcmd = NULL;
|
||||||
return;
|
return;
|
||||||
|
@@ -391,7 +391,7 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s,
|
|||||||
// parse the address range
|
// parse the address range
|
||||||
save_cursor = curwin->w_cursor;
|
save_cursor = curwin->w_cursor;
|
||||||
curwin->w_cursor = s->search_start;
|
curwin->w_cursor = s->search_start;
|
||||||
parse_cmd_address(&ea, &dummy);
|
parse_cmd_address(&ea, &dummy, true);
|
||||||
if (ea.addr_count > 0) {
|
if (ea.addr_count > 0) {
|
||||||
// Allow for reverse match.
|
// Allow for reverse match.
|
||||||
if (ea.line2 < ea.line1) {
|
if (ea.line2 < ea.line1) {
|
||||||
|
@@ -796,6 +796,10 @@ func Test_keep_last_search_pattern()
|
|||||||
call feedkeys(":/foo/s//\<Esc>", 'ntx')
|
call feedkeys(":/foo/s//\<Esc>", 'ntx')
|
||||||
call assert_equal('bar', @/)
|
call assert_equal('bar', @/)
|
||||||
|
|
||||||
|
" no error message if pattern not found
|
||||||
|
call feedkeys(":/xyz/s//\<Esc>", 'ntx')
|
||||||
|
call assert_equal('bar', @/)
|
||||||
|
|
||||||
bwipe!
|
bwipe!
|
||||||
call test_override("ALL", 0)
|
call test_override("ALL", 0)
|
||||||
set noincsearch
|
set noincsearch
|
||||||
|
Reference in New Issue
Block a user