Bram Moolenaar
unread,Nov 14, 2020, 8:24:19 AM11/14/20Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to vim...@googlegroups.com
Patch 8.2.1983
Problem: ml_get error when using <Cmd> to open a terminal.
Solution: If the window changed reset the incsearch state. (closes #7289)
Files: src/ex_getln.c, src/testdir/test_terminal.vim,
src/testdir/dumps/Test_terminal_from_cmd.dump
*** ../vim-8.2.1982/src/ex_getln.c 2020-11-12 14:20:32.021927293 +0100
--- src/ex_getln.c 2020-11-14 14:20:37.418595911 +0100
***************
*** 142,147 ****
--- 142,148 ----
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;
***************
*** 154,159 ****
--- 155,161 ----
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;
***************
*** 1703,1715 ****
// 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
c = safe_vgetc();
! while (c == K_IGNORE || c == K_NOP);
if (c == K_COMMAND
&& do_cmdline(NULL, getcmdkeycmd, NULL, DOCMD_NOWAIT) == OK)
--- 1705,1717 ----
// Trigger SafeState if nothing is pending.
may_trigger_safestate(xpc.xp_numfiles <= 0);
// 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);
if (c == K_COMMAND
&& do_cmdline(NULL, getcmdkeycmd, NULL, DOCMD_NOWAIT) == OK)
***************
*** 2327,2332 ****
--- 2329,2339 ----
#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);
*** ../vim-8.2.1982/src/testdir/test_terminal.vim 2020-11-12 15:12:12.034017200 +0100
--- src/testdir/test_terminal.vim 2020-11-14 14:16:57.383104281 +0100
***************
*** 1200,1206 ****
unlet s:called
au! repro
! endfunction
func Check_dump01(off)
call assert_equal('one two three four five', trim(getline(a:off + 1)))
--- 1200,1229 ----
unlet s:called
au! repro
! 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)))
*** ../vim-8.2.1982/src/testdir/dumps/Test_terminal_from_cmd.dump 2020-11-14 14:21:19.558498677 +0100
--- src/testdir/dumps/Test_terminal_from_cmd.dump 2020-11-14 14:17:09.731075730 +0100
***************
*** 0 ****
--- 1,20 ----
+ | +0&#ffffff0@74
+ @75
+ @75
+ @75
+ @75
+ @75
+ @75
+ @75
+ @75
+ |!+2#ffffff16#00e0003|/|b|i|n|/|s|h| |[|f|i|n|i|s|h|e|d|]| @37|0|,|0|-|1| @9|A|l@1
+ |a+0#0000000#ffffff0| @73
+ |b| @73
+ |c| @73
+ |~+0#4040ff13&| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |[+1#0000000&|N|o| |N|a|m|e|]| |[|+|]| @43|3|,|1| @11|A|l@1
+ |/+0&&> @73
*** ../vim-8.2.1982/src/version.c 2020-11-14 13:15:20.066728402 +0100
--- src/version.c 2020-11-14 13:55:55.970074449 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1983,
/**/