typedef struct {
pos_T search_start; // where 'incsearch' starts searching
pos_T save_cursor;
+ int winid; // window where this state is valid
viewstate_T init_viewstate;
viewstate_T old_viewstate;
pos_T match_start;
static void
init_incsearch_state(incsearch_state_T *is_state)
{
+ is_state->winid = curwin->w_id;
is_state->match_start = curwin->w_cursor;
is_state->did_incsearch = FALSE;
is_state->incsearch_postponed = FALSE;
// Trigger SafeState if nothing is pending.
may_trigger_safestate(xpc.xp_numfiles <= 0);
- cursorcmd(); // set the cursor on the right spot
-
// Get a character. Ignore K_IGNORE and K_NOP, they should not do
// anything, such as stop completion.
do
+ {
+ cursorcmd(); // set the cursor on the right spot
c = safe_vgetc();
- while (c == K_IGNORE || c == K_NOP);
+ } while (c == K_IGNORE || c == K_NOP);
if (c == K_COMMAND
&& do_cmdline(NULL, getcmdkeycmd, NULL, DOCMD_NOWAIT) == OK)
#endif
cmdline_changed:
+#ifdef FEAT_SEARCH_EXTRA
+ // If the window changed incremental search state is not valid.
+ if (is_state.winid != curwin->w_id)
+ init_incsearch_state(&is_state);
+#endif
// Trigger CmdlineChanged autocommands.
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED);
unlet s:called
au! repro
-endfunction
+endfunc
+
+func Test_open_term_from_cmd()
+ CheckUnix
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ call setline(1, ['a', 'b', 'c'])
+ 3
+ set incsearch
+ cnoremap <F3> <Cmd>call term_start(['/bin/sh', '-c', ':'])<CR>
+ END
+ call writefile(lines, 'Xopenterm')
+ let buf = RunVimInTerminal('-S Xopenterm', {})
+
+ " this opens a window, incsearch should not use the old cursor position
+ call term_sendkeys(buf, "/\<F3>")
+ call VerifyScreenDump(buf, 'Test_terminal_from_cmd', {})
+ call term_sendkeys(buf, "\<Esc>")
+ call term_sendkeys(buf, ":q\<CR>")
+
+ call StopVimInTerminal(buf)
+ call delete('Xopenterm')
+endfunc
func Check_dump01(off)
call assert_equal('one two three four five', trim(getline(a:off + 1)))