mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.1.0286: 'incsearch' does not apply to :smagic and :snomagic
Problem: 'incsearch' does not apply to :smagic and :snomagic.
Solution: Add support. (Hirohito Higashi)
167ae42685
This commit is contained in:
parent
68f6abef16
commit
c0102c140c
@ -157,6 +157,7 @@ typedef struct {
|
|||||||
pos_T match_end;
|
pos_T match_end;
|
||||||
bool did_incsearch;
|
bool did_incsearch;
|
||||||
bool incsearch_postponed;
|
bool incsearch_postponed;
|
||||||
|
int magic_save;
|
||||||
} incsearch_state_T;
|
} incsearch_state_T;
|
||||||
|
|
||||||
typedef struct command_line_state {
|
typedef struct command_line_state {
|
||||||
@ -263,6 +264,7 @@ static void init_incsearch_state(incsearch_state_T *s)
|
|||||||
s->match_start = curwin->w_cursor;
|
s->match_start = curwin->w_cursor;
|
||||||
s->did_incsearch = false;
|
s->did_incsearch = false;
|
||||||
s->incsearch_postponed = false;
|
s->incsearch_postponed = false;
|
||||||
|
s->magic_save = p_magic;
|
||||||
clearpos(&s->match_end);
|
clearpos(&s->match_end);
|
||||||
s->save_cursor = curwin->w_cursor; // may be restored later
|
s->save_cursor = curwin->w_cursor; // may be restored later
|
||||||
s->search_start = curwin->w_cursor;
|
s->search_start = curwin->w_cursor;
|
||||||
@ -310,8 +312,17 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s,
|
|||||||
for (p = cmd; ASCII_ISALPHA(*p); p++) {}
|
for (p = cmd; ASCII_ISALPHA(*p); p++) {}
|
||||||
if (*skipwhite(p) != NUL
|
if (*skipwhite(p) != NUL
|
||||||
&& (STRNCMP(cmd, "substitute", p - cmd) == 0
|
&& (STRNCMP(cmd, "substitute", p - cmd) == 0
|
||||||
|
|| STRNCMP(cmd, "smagic", p - cmd) == 0
|
||||||
|
|| STRNCMP(cmd, "snomagic", MAX(p - cmd, 3)) == 0
|
||||||
|| STRNCMP(cmd, "global", p - cmd) == 0
|
|| STRNCMP(cmd, "global", p - cmd) == 0
|
||||||
|| STRNCMP(cmd, "vglobal", p - cmd) == 0)) {
|
|| STRNCMP(cmd, "vglobal", p - cmd) == 0)) {
|
||||||
|
if (*cmd == 's' && cmd[1] == 'm') {
|
||||||
|
p_magic = true;
|
||||||
|
}
|
||||||
|
else if (*cmd == 's' && cmd[1] == 'n') {
|
||||||
|
p_magic = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Check for "global!/".
|
// Check for "global!/".
|
||||||
if (*cmd == 'g' && *p == '!') {
|
if (*cmd == 'g' && *p == '!') {
|
||||||
p++;
|
p++;
|
||||||
@ -557,6 +568,7 @@ static void finish_incsearch_highlighting(int gotesc, incsearch_state_T *s,
|
|||||||
} else {
|
} else {
|
||||||
redraw_all_later(SOME_VALID);
|
redraw_all_later(SOME_VALID);
|
||||||
}
|
}
|
||||||
|
p_magic = s->magic_save;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,6 +392,14 @@ func Test_search_cmdline3s()
|
|||||||
undo
|
undo
|
||||||
call feedkeys(":%substitute/the\<c-l>/xxx\<cr>", 'tx')
|
call feedkeys(":%substitute/the\<c-l>/xxx\<cr>", 'tx')
|
||||||
call assert_equal(' 2 xxxe', getline('.'))
|
call assert_equal(' 2 xxxe', getline('.'))
|
||||||
|
undo
|
||||||
|
call feedkeys(":%smagic/the.e/xxx\<cr>", 'tx')
|
||||||
|
call assert_equal(' 2 xxx', getline('.'))
|
||||||
|
undo
|
||||||
|
call assert_fails(":%snomagic/the.e/xxx\<cr>", 'E486')
|
||||||
|
"
|
||||||
|
call feedkeys(":%snomagic/the\\.e/xxx\<cr>", 'tx')
|
||||||
|
call assert_equal(' 2 xxx', getline('.'))
|
||||||
|
|
||||||
call Incsearch_cleanup()
|
call Incsearch_cleanup()
|
||||||
endfunc
|
endfunc
|
||||||
|
Loading…
Reference in New Issue
Block a user