# HG changeset patch # User Christian Brabandt # Date 1534275904 -7200 # Node ID 35e7ead872dbb6155eecde86f5b1ebc2ae8fd7e9 # Parent a259914eb676038eeac0ca8aff3c8a1ecac2c7b3 patch 8.1.0286: 'incsearch' does not apply to :smagic and :snomagic commit https://github.com/vim/vim/commit/167ae42685dcd430800c51ac7339f7f0938a3e70 Author: Bram Moolenaar Date: Tue Aug 14 21:32:21 2018 +0200 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) diff --git a/src/ex_getln.c b/src/ex_getln.c --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -231,6 +231,7 @@ typedef struct { pos_T match_end; int did_incsearch; int incsearch_postponed; + int magic_save; } incsearch_state_T; static void @@ -239,6 +240,7 @@ init_incsearch_state(incsearch_state_T * is_state->match_start = curwin->w_cursor; is_state->did_incsearch = FALSE; is_state->incsearch_postponed = FALSE; + is_state->magic_save = p_magic; CLEAR_POS(&is_state->match_end); is_state->save_cursor = curwin->w_cursor; // may be restored later is_state->search_start = curwin->w_cursor; @@ -308,9 +310,16 @@ do_incsearch_highlighting(int firstc, in ; if (*skipwhite(p) != NUL && (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, "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!/". if (*cmd == 'g' && *p == '!') { @@ -392,6 +401,7 @@ finish_incsearch_highlighting( update_screen(SOME_VALID); else redraw_all_later(SOME_VALID); + p_magic = is_state->magic_save; } } diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim --- a/src/testdir/test_search.vim +++ b/src/testdir/test_search.vim @@ -384,6 +384,14 @@ func Test_search_cmdline3s() undo call feedkeys(":%substitute/the\/xxx\", 'tx') call assert_equal(' 2 xxxe', getline('.')) + undo + call feedkeys(":%smagic/the.e/xxx\", 'tx') + call assert_equal(' 2 xxx', getline('.')) + undo + call assert_fails(":%snomagic/the.e/xxx\", 'E486') + " + call feedkeys(":%snomagic/the\\.e/xxx\", 'tx') + call assert_equal(' 2 xxx', getline('.')) call Incsearch_cleanup() endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -795,6 +795,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 286, +/**/ 285, /**/ 284,