forked from aniani/vim
patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Problem: ml_get error when win_execute redraws with Visual selection. Solution: Disable Visual area temporarily. (closes #9479)
This commit is contained in:
@@ -931,8 +931,7 @@ find_win_for_buf(
|
|||||||
void
|
void
|
||||||
switch_to_win_for_buf(
|
switch_to_win_for_buf(
|
||||||
buf_T *buf,
|
buf_T *buf,
|
||||||
win_T **save_curwinp,
|
switchwin_T *switchwin,
|
||||||
tabpage_T **save_curtabp,
|
|
||||||
bufref_T *save_curbuf)
|
bufref_T *save_curbuf)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
win_T *wp;
|
||||||
@@ -940,21 +939,20 @@ switch_to_win_for_buf(
|
|||||||
|
|
||||||
if (find_win_for_buf(buf, &wp, &tp) == FAIL)
|
if (find_win_for_buf(buf, &wp, &tp) == FAIL)
|
||||||
switch_buffer(save_curbuf, buf);
|
switch_buffer(save_curbuf, buf);
|
||||||
else if (switch_win(save_curwinp, save_curtabp, wp, tp, TRUE) == FAIL)
|
else if (switch_win(switchwin, wp, tp, TRUE) == FAIL)
|
||||||
{
|
{
|
||||||
restore_win(*save_curwinp, *save_curtabp, TRUE);
|
restore_win(switchwin, TRUE);
|
||||||
switch_buffer(save_curbuf, buf);
|
switch_buffer(save_curbuf, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
restore_win_for_buf(
|
restore_win_for_buf(
|
||||||
win_T *save_curwin,
|
switchwin_T *switchwin,
|
||||||
tabpage_T *save_curtab,
|
|
||||||
bufref_T *save_curbuf)
|
bufref_T *save_curbuf)
|
||||||
{
|
{
|
||||||
if (save_curbuf->br_buf == NULL)
|
if (save_curbuf->br_buf == NULL)
|
||||||
restore_win(save_curwin, save_curtab, TRUE);
|
restore_win(switchwin, TRUE);
|
||||||
else
|
else
|
||||||
restore_buffer(save_curbuf);
|
restore_buffer(save_curbuf);
|
||||||
}
|
}
|
||||||
|
@@ -6864,8 +6864,7 @@ f_line(typval_T *argvars, typval_T *rettv)
|
|||||||
int id;
|
int id;
|
||||||
tabpage_T *tp;
|
tabpage_T *tp;
|
||||||
win_T *wp;
|
win_T *wp;
|
||||||
win_T *save_curwin;
|
switchwin_T switchwin;
|
||||||
tabpage_T *save_curtab;
|
|
||||||
|
|
||||||
if (in_vim9script()
|
if (in_vim9script()
|
||||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||||
@@ -6879,13 +6878,12 @@ f_line(typval_T *argvars, typval_T *rettv)
|
|||||||
wp = win_id2wp_tp(id, &tp);
|
wp = win_id2wp_tp(id, &tp);
|
||||||
if (wp != NULL && tp != NULL)
|
if (wp != NULL && tp != NULL)
|
||||||
{
|
{
|
||||||
if (switch_win_noblock(&save_curwin, &save_curtab, wp, tp, TRUE)
|
if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
|
||||||
== OK)
|
|
||||||
{
|
{
|
||||||
check_cursor();
|
check_cursor();
|
||||||
fp = var2fpos(&argvars[0], TRUE, &fnum, FALSE);
|
fp = var2fpos(&argvars[0], TRUE, &fnum, FALSE);
|
||||||
}
|
}
|
||||||
restore_win_noblock(save_curwin, save_curtab, TRUE);
|
restore_win_noblock(&switchwin, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -3769,8 +3769,7 @@ getwinvar(
|
|||||||
dictitem_T *v;
|
dictitem_T *v;
|
||||||
tabpage_T *tp = NULL;
|
tabpage_T *tp = NULL;
|
||||||
int done = FALSE;
|
int done = FALSE;
|
||||||
win_T *oldcurwin;
|
switchwin_T switchwin;
|
||||||
tabpage_T *oldtabpage;
|
|
||||||
int need_switch_win;
|
int need_switch_win;
|
||||||
|
|
||||||
if (off == 1)
|
if (off == 1)
|
||||||
@@ -3791,7 +3790,7 @@ getwinvar(
|
|||||||
// autocommands get blocked.
|
// autocommands get blocked.
|
||||||
need_switch_win = !(tp == curtab && win == curwin);
|
need_switch_win = !(tp == curtab && win == curwin);
|
||||||
if (!need_switch_win
|
if (!need_switch_win
|
||||||
|| switch_win(&oldcurwin, &oldtabpage, win, tp, TRUE) == OK)
|
|| switch_win(&switchwin, win, tp, TRUE) == OK)
|
||||||
{
|
{
|
||||||
if (*varname == '&')
|
if (*varname == '&')
|
||||||
{
|
{
|
||||||
@@ -3826,7 +3825,7 @@ getwinvar(
|
|||||||
|
|
||||||
if (need_switch_win)
|
if (need_switch_win)
|
||||||
// restore previous notion of curwin
|
// restore previous notion of curwin
|
||||||
restore_win(oldcurwin, oldtabpage, TRUE);
|
restore_win(&switchwin, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!done && argvars[off + 2].v_type != VAR_UNKNOWN)
|
if (!done && argvars[off + 2].v_type != VAR_UNKNOWN)
|
||||||
@@ -3869,8 +3868,7 @@ set_option_from_tv(char_u *varname, typval_T *varp)
|
|||||||
setwinvar(typval_T *argvars, int off)
|
setwinvar(typval_T *argvars, int off)
|
||||||
{
|
{
|
||||||
win_T *win;
|
win_T *win;
|
||||||
win_T *save_curwin;
|
switchwin_T switchwin;
|
||||||
tabpage_T *save_curtab;
|
|
||||||
int need_switch_win;
|
int need_switch_win;
|
||||||
char_u *varname, *winvarname;
|
char_u *varname, *winvarname;
|
||||||
typval_T *varp;
|
typval_T *varp;
|
||||||
@@ -3891,7 +3889,7 @@ setwinvar(typval_T *argvars, int off)
|
|||||||
{
|
{
|
||||||
need_switch_win = !(tp == curtab && win == curwin);
|
need_switch_win = !(tp == curtab && win == curwin);
|
||||||
if (!need_switch_win
|
if (!need_switch_win
|
||||||
|| switch_win(&save_curwin, &save_curtab, win, tp, TRUE) == OK)
|
|| switch_win(&switchwin, win, tp, TRUE) == OK)
|
||||||
{
|
{
|
||||||
if (*varname == '&')
|
if (*varname == '&')
|
||||||
set_option_from_tv(varname + 1, varp);
|
set_option_from_tv(varname + 1, varp);
|
||||||
@@ -3908,7 +3906,7 @@ setwinvar(typval_T *argvars, int off)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (need_switch_win)
|
if (need_switch_win)
|
||||||
restore_win(save_curwin, save_curtab, TRUE);
|
restore_win(&switchwin, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4165,8 +4163,8 @@ get_clear_redir_ga(void)
|
|||||||
void
|
void
|
||||||
f_gettabvar(typval_T *argvars, typval_T *rettv)
|
f_gettabvar(typval_T *argvars, typval_T *rettv)
|
||||||
{
|
{
|
||||||
win_T *oldcurwin;
|
switchwin_T switchwin;
|
||||||
tabpage_T *tp, *oldtabpage;
|
tabpage_T *tp;
|
||||||
dictitem_T *v;
|
dictitem_T *v;
|
||||||
char_u *varname;
|
char_u *varname;
|
||||||
int done = FALSE;
|
int done = FALSE;
|
||||||
@@ -4185,7 +4183,7 @@ f_gettabvar(typval_T *argvars, typval_T *rettv)
|
|||||||
{
|
{
|
||||||
// Set tp to be our tabpage, temporarily. Also set the window to the
|
// Set tp to be our tabpage, temporarily. Also set the window to the
|
||||||
// first window in the tabpage, otherwise the window is not valid.
|
// first window in the tabpage, otherwise the window is not valid.
|
||||||
if (switch_win(&oldcurwin, &oldtabpage,
|
if (switch_win(&switchwin,
|
||||||
tp == curtab || tp->tp_firstwin == NULL ? firstwin
|
tp == curtab || tp->tp_firstwin == NULL ? firstwin
|
||||||
: tp->tp_firstwin, tp, TRUE) == OK)
|
: tp->tp_firstwin, tp, TRUE) == OK)
|
||||||
{
|
{
|
||||||
@@ -4200,7 +4198,7 @@ f_gettabvar(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// restore previous notion of curwin
|
// restore previous notion of curwin
|
||||||
restore_win(oldcurwin, oldtabpage, TRUE);
|
restore_win(&switchwin, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!done && argvars[2].v_type != VAR_UNKNOWN)
|
if (!done && argvars[2].v_type != VAR_UNKNOWN)
|
||||||
|
@@ -689,8 +689,7 @@ f_win_execute(typval_T *argvars, typval_T *rettv)
|
|||||||
int id;
|
int id;
|
||||||
tabpage_T *tp;
|
tabpage_T *tp;
|
||||||
win_T *wp;
|
win_T *wp;
|
||||||
win_T *save_curwin;
|
switchwin_T switchwin;
|
||||||
tabpage_T *save_curtab;
|
|
||||||
|
|
||||||
// Return an empty string if something fails.
|
// Return an empty string if something fails.
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
@@ -727,12 +726,12 @@ f_win_execute(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (switch_win_noblock(&save_curwin, &save_curtab, wp, tp, TRUE) == OK)
|
if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
|
||||||
{
|
{
|
||||||
check_cursor();
|
check_cursor();
|
||||||
execute_common(argvars, rettv, 1);
|
execute_common(argvars, rettv, 1);
|
||||||
}
|
}
|
||||||
restore_win_noblock(save_curwin, save_curtab, TRUE);
|
restore_win_noblock(&switchwin, TRUE);
|
||||||
#ifdef FEAT_AUTOCHDIR
|
#ifdef FEAT_AUTOCHDIR
|
||||||
if (apply_acd)
|
if (apply_acd)
|
||||||
do_autochdir();
|
do_autochdir();
|
||||||
@@ -1247,14 +1246,13 @@ f_winwidth(typval_T *argvars, typval_T *rettv)
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
switch_win(
|
switch_win(
|
||||||
win_T **save_curwin,
|
switchwin_T *switchwin,
|
||||||
tabpage_T **save_curtab,
|
|
||||||
win_T *win,
|
win_T *win,
|
||||||
tabpage_T *tp,
|
tabpage_T *tp,
|
||||||
int no_display)
|
int no_display)
|
||||||
{
|
{
|
||||||
block_autocmds();
|
block_autocmds();
|
||||||
return switch_win_noblock(save_curwin, save_curtab, win, tp, no_display);
|
return switch_win_noblock(switchwin, win, tp, no_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1262,16 +1260,25 @@ switch_win(
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
switch_win_noblock(
|
switch_win_noblock(
|
||||||
win_T **save_curwin,
|
switchwin_T *switchwin,
|
||||||
tabpage_T **save_curtab,
|
|
||||||
win_T *win,
|
win_T *win,
|
||||||
tabpage_T *tp,
|
tabpage_T *tp,
|
||||||
int no_display)
|
int no_display)
|
||||||
{
|
{
|
||||||
*save_curwin = curwin;
|
CLEAR_POINTER(switchwin);
|
||||||
|
switchwin->sw_curwin = curwin;
|
||||||
|
if (win == curwin)
|
||||||
|
switchwin->sw_same_win = TRUE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Disable Visual selection, because redrawing may fail.
|
||||||
|
switchwin->sw_visual_active = VIsual_active;
|
||||||
|
VIsual_active = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (tp != NULL)
|
if (tp != NULL)
|
||||||
{
|
{
|
||||||
*save_curtab = curtab;
|
switchwin->sw_curtab = curtab;
|
||||||
if (no_display)
|
if (no_display)
|
||||||
{
|
{
|
||||||
curtab->tp_firstwin = firstwin;
|
curtab->tp_firstwin = firstwin;
|
||||||
@@ -1299,11 +1306,10 @@ switch_win_noblock(
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
restore_win(
|
restore_win(
|
||||||
win_T *save_curwin,
|
switchwin_T *switchwin,
|
||||||
tabpage_T *save_curtab,
|
|
||||||
int no_display)
|
int no_display)
|
||||||
{
|
{
|
||||||
restore_win_noblock(save_curwin, save_curtab, no_display);
|
restore_win_noblock(switchwin, no_display);
|
||||||
unblock_autocmds();
|
unblock_autocmds();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1312,28 +1318,31 @@ restore_win(
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
restore_win_noblock(
|
restore_win_noblock(
|
||||||
win_T *save_curwin,
|
switchwin_T *switchwin,
|
||||||
tabpage_T *save_curtab,
|
|
||||||
int no_display)
|
int no_display)
|
||||||
{
|
{
|
||||||
if (save_curtab != NULL && valid_tabpage(save_curtab))
|
if (switchwin->sw_curtab != NULL && valid_tabpage(switchwin->sw_curtab))
|
||||||
{
|
{
|
||||||
if (no_display)
|
if (no_display)
|
||||||
{
|
{
|
||||||
curtab->tp_firstwin = firstwin;
|
curtab->tp_firstwin = firstwin;
|
||||||
curtab->tp_lastwin = lastwin;
|
curtab->tp_lastwin = lastwin;
|
||||||
curtab->tp_topframe = topframe;
|
curtab->tp_topframe = topframe;
|
||||||
curtab = save_curtab;
|
curtab = switchwin->sw_curtab;
|
||||||
firstwin = curtab->tp_firstwin;
|
firstwin = curtab->tp_firstwin;
|
||||||
lastwin = curtab->tp_lastwin;
|
lastwin = curtab->tp_lastwin;
|
||||||
topframe = curtab->tp_topframe;
|
topframe = curtab->tp_topframe;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
goto_tabpage_tp(save_curtab, FALSE, FALSE);
|
goto_tabpage_tp(switchwin->sw_curtab, FALSE, FALSE);
|
||||||
}
|
}
|
||||||
if (win_valid(save_curwin))
|
|
||||||
|
if (!switchwin->sw_same_win)
|
||||||
|
VIsual_active = switchwin->sw_visual_active;
|
||||||
|
|
||||||
|
if (win_valid(switchwin->sw_curwin))
|
||||||
{
|
{
|
||||||
curwin = save_curwin;
|
curwin = switchwin->sw_curwin;
|
||||||
curbuf = curwin->w_buffer;
|
curbuf = curwin->w_buffer;
|
||||||
}
|
}
|
||||||
# ifdef FEAT_PROP_POPUP
|
# ifdef FEAT_PROP_POPUP
|
||||||
|
@@ -3529,8 +3529,7 @@ set_option_value_for(
|
|||||||
int opt_type,
|
int opt_type,
|
||||||
void *from)
|
void *from)
|
||||||
{
|
{
|
||||||
win_T *save_curwin = NULL;
|
switchwin_T switchwin;
|
||||||
tabpage_T *save_curtab = NULL;
|
|
||||||
bufref_T save_curbuf;
|
bufref_T save_curbuf;
|
||||||
int set_ret = 0;
|
int set_ret = 0;
|
||||||
|
|
||||||
@@ -3538,17 +3537,17 @@ set_option_value_for(
|
|||||||
switch (opt_type)
|
switch (opt_type)
|
||||||
{
|
{
|
||||||
case SREQ_WIN:
|
case SREQ_WIN:
|
||||||
if (switch_win(&save_curwin, &save_curtab, (win_T *)from,
|
if (switch_win(&switchwin, (win_T *)from,
|
||||||
win_find_tabpage((win_T *)from), FALSE) == FAIL)
|
win_find_tabpage((win_T *)from), FALSE) == FAIL)
|
||||||
{
|
{
|
||||||
restore_win(save_curwin, save_curtab, TRUE);
|
restore_win(&switchwin, TRUE);
|
||||||
if (VimTryEnd())
|
if (VimTryEnd())
|
||||||
return -1;
|
return -1;
|
||||||
PyErr_SET_VIM(N_("problem while switching windows"));
|
PyErr_SET_VIM(N_("problem while switching windows"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
set_ret = set_option_value_err(key, numval, stringval, opt_flags);
|
set_ret = set_option_value_err(key, numval, stringval, opt_flags);
|
||||||
restore_win(save_curwin, save_curtab, TRUE);
|
restore_win(&switchwin, TRUE);
|
||||||
break;
|
break;
|
||||||
case SREQ_BUF:
|
case SREQ_BUF:
|
||||||
switch_buffer(&save_curbuf, (buf_T *)from);
|
switch_buffer(&save_curbuf, (buf_T *)from);
|
||||||
@@ -4410,8 +4409,7 @@ py_fix_cursor(linenr_T lo, linenr_T hi, linenr_T extra)
|
|||||||
SetBufferLine(buf_T *buf, PyInt n, PyObject *line, PyInt *len_change)
|
SetBufferLine(buf_T *buf, PyInt n, PyObject *line, PyInt *len_change)
|
||||||
{
|
{
|
||||||
bufref_T save_curbuf = {NULL, 0, 0};
|
bufref_T save_curbuf = {NULL, 0, 0};
|
||||||
win_T *save_curwin = NULL;
|
switchwin_T switchwin;
|
||||||
tabpage_T *save_curtab = NULL;
|
|
||||||
|
|
||||||
// First of all, we check the type of the supplied Python object.
|
// First of all, we check the type of the supplied Python object.
|
||||||
// There are three cases:
|
// There are three cases:
|
||||||
@@ -4421,7 +4419,8 @@ SetBufferLine(buf_T *buf, PyInt n, PyObject *line, PyInt *len_change)
|
|||||||
if (line == Py_None || line == NULL)
|
if (line == Py_None || line == NULL)
|
||||||
{
|
{
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
switch_to_win_for_buf(buf, &save_curwin, &save_curtab, &save_curbuf);
|
switchwin.sw_curwin = NULL;
|
||||||
|
switch_to_win_for_buf(buf, &switchwin, &save_curbuf);
|
||||||
|
|
||||||
VimTryStart();
|
VimTryStart();
|
||||||
|
|
||||||
@@ -4431,7 +4430,7 @@ SetBufferLine(buf_T *buf, PyInt n, PyObject *line, PyInt *len_change)
|
|||||||
RAISE_DELETE_LINE_FAIL;
|
RAISE_DELETE_LINE_FAIL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (buf == curbuf && (save_curwin != NULL
|
if (buf == curbuf && (switchwin.sw_curwin != NULL
|
||||||
|| save_curbuf.br_buf == NULL))
|
|| save_curbuf.br_buf == NULL))
|
||||||
// Using an existing window for the buffer, adjust the cursor
|
// Using an existing window for the buffer, adjust the cursor
|
||||||
// position.
|
// position.
|
||||||
@@ -4442,7 +4441,7 @@ SetBufferLine(buf_T *buf, PyInt n, PyObject *line, PyInt *len_change)
|
|||||||
deleted_lines_mark((linenr_T)n, 1L);
|
deleted_lines_mark((linenr_T)n, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
restore_win_for_buf(save_curwin, save_curtab, &save_curbuf);
|
restore_win_for_buf(&switchwin, &save_curbuf);
|
||||||
|
|
||||||
if (VimTryEnd())
|
if (VimTryEnd())
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -4463,7 +4462,7 @@ SetBufferLine(buf_T *buf, PyInt n, PyObject *line, PyInt *len_change)
|
|||||||
|
|
||||||
// We do not need to free "save" if ml_replace() consumes it.
|
// We do not need to free "save" if ml_replace() consumes it.
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
switch_to_win_for_buf(buf, &save_curwin, &save_curtab, &save_curbuf);
|
switch_to_win_for_buf(buf, &switchwin, &save_curbuf);
|
||||||
|
|
||||||
if (u_savesub((linenr_T)n) == FAIL)
|
if (u_savesub((linenr_T)n) == FAIL)
|
||||||
{
|
{
|
||||||
@@ -4478,7 +4477,7 @@ SetBufferLine(buf_T *buf, PyInt n, PyObject *line, PyInt *len_change)
|
|||||||
else
|
else
|
||||||
changed_bytes((linenr_T)n, 0);
|
changed_bytes((linenr_T)n, 0);
|
||||||
|
|
||||||
restore_win_for_buf(save_curwin, save_curtab, &save_curbuf);
|
restore_win_for_buf(&switchwin, &save_curbuf);
|
||||||
|
|
||||||
// Check that the cursor is not beyond the end of the line now.
|
// Check that the cursor is not beyond the end of the line now.
|
||||||
if (buf == curbuf)
|
if (buf == curbuf)
|
||||||
@@ -4517,8 +4516,7 @@ SetBufferLineList(
|
|||||||
PyInt *len_change)
|
PyInt *len_change)
|
||||||
{
|
{
|
||||||
bufref_T save_curbuf = {NULL, 0, 0};
|
bufref_T save_curbuf = {NULL, 0, 0};
|
||||||
win_T *save_curwin = NULL;
|
switchwin_T switchwin;
|
||||||
tabpage_T *save_curtab = NULL;
|
|
||||||
|
|
||||||
// First of all, we check the type of the supplied Python object.
|
// First of all, we check the type of the supplied Python object.
|
||||||
// There are three cases:
|
// There are three cases:
|
||||||
@@ -4532,7 +4530,8 @@ SetBufferLineList(
|
|||||||
|
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
VimTryStart();
|
VimTryStart();
|
||||||
switch_to_win_for_buf(buf, &save_curwin, &save_curtab, &save_curbuf);
|
switchwin.sw_curwin = NULL;
|
||||||
|
switch_to_win_for_buf(buf, &switchwin, &save_curbuf);
|
||||||
|
|
||||||
if (u_savedel((linenr_T)lo, (long)n) == FAIL)
|
if (u_savedel((linenr_T)lo, (long)n) == FAIL)
|
||||||
RAISE_UNDO_FAIL;
|
RAISE_UNDO_FAIL;
|
||||||
@@ -4546,7 +4545,7 @@ SetBufferLineList(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (buf == curbuf && (save_curwin != NULL
|
if (buf == curbuf && (switchwin.sw_curwin != NULL
|
||||||
|| save_curbuf.br_buf == NULL))
|
|| save_curbuf.br_buf == NULL))
|
||||||
// Using an existing window for the buffer, adjust the cursor
|
// Using an existing window for the buffer, adjust the cursor
|
||||||
// position.
|
// position.
|
||||||
@@ -4557,7 +4556,7 @@ SetBufferLineList(
|
|||||||
deleted_lines_mark((linenr_T)lo, (long)i);
|
deleted_lines_mark((linenr_T)lo, (long)i);
|
||||||
}
|
}
|
||||||
|
|
||||||
restore_win_for_buf(save_curwin, save_curtab, &save_curbuf);
|
restore_win_for_buf(&switchwin, &save_curbuf);
|
||||||
|
|
||||||
if (VimTryEnd())
|
if (VimTryEnd())
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -4605,7 +4604,8 @@ SetBufferLineList(
|
|||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
|
||||||
// START of region without "return". Must call restore_buffer()!
|
// START of region without "return". Must call restore_buffer()!
|
||||||
switch_to_win_for_buf(buf, &save_curwin, &save_curtab, &save_curbuf);
|
switchwin.sw_curwin = NULL;
|
||||||
|
switch_to_win_for_buf(buf, &switchwin, &save_curbuf);
|
||||||
|
|
||||||
if (u_save((linenr_T)(lo-1), (linenr_T)hi) == FAIL)
|
if (u_save((linenr_T)(lo-1), (linenr_T)hi) == FAIL)
|
||||||
RAISE_UNDO_FAIL;
|
RAISE_UNDO_FAIL;
|
||||||
@@ -4680,14 +4680,14 @@ SetBufferLineList(
|
|||||||
(long)MAXLNUM, (long)extra);
|
(long)MAXLNUM, (long)extra);
|
||||||
changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra);
|
changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra);
|
||||||
|
|
||||||
if (buf == curbuf && (save_curwin != NULL
|
if (buf == curbuf && (switchwin.sw_curwin != NULL
|
||||||
|| save_curbuf.br_buf == NULL))
|
|| save_curbuf.br_buf == NULL))
|
||||||
// Using an existing window for the buffer, adjust the cursor
|
// Using an existing window for the buffer, adjust the cursor
|
||||||
// position.
|
// position.
|
||||||
py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)extra);
|
py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)extra);
|
||||||
|
|
||||||
// END of region without "return".
|
// END of region without "return".
|
||||||
restore_win_for_buf(save_curwin, save_curtab, &save_curbuf);
|
restore_win_for_buf(&switchwin, &save_curbuf);
|
||||||
|
|
||||||
if (VimTryEnd())
|
if (VimTryEnd())
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -4717,8 +4717,7 @@ SetBufferLineList(
|
|||||||
InsertBufferLines(buf_T *buf, PyInt n, PyObject *lines, PyInt *len_change)
|
InsertBufferLines(buf_T *buf, PyInt n, PyObject *lines, PyInt *len_change)
|
||||||
{
|
{
|
||||||
bufref_T save_curbuf = {NULL, 0, 0};
|
bufref_T save_curbuf = {NULL, 0, 0};
|
||||||
win_T *save_curwin = NULL;
|
switchwin_T switchwin;
|
||||||
tabpage_T *save_curtab = NULL;
|
|
||||||
|
|
||||||
// First of all, we check the type of the supplied Python object.
|
// First of all, we check the type of the supplied Python object.
|
||||||
// It must be a string or a list, or the call is in error.
|
// It must be a string or a list, or the call is in error.
|
||||||
@@ -4731,7 +4730,7 @@ InsertBufferLines(buf_T *buf, PyInt n, PyObject *lines, PyInt *len_change)
|
|||||||
|
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
VimTryStart();
|
VimTryStart();
|
||||||
switch_to_win_for_buf(buf, &save_curwin, &save_curtab, &save_curbuf);
|
switch_to_win_for_buf(buf, &switchwin, &save_curbuf);
|
||||||
|
|
||||||
if (u_save((linenr_T)n, (linenr_T)(n + 1)) == FAIL)
|
if (u_save((linenr_T)n, (linenr_T)(n + 1)) == FAIL)
|
||||||
RAISE_UNDO_FAIL;
|
RAISE_UNDO_FAIL;
|
||||||
@@ -4743,7 +4742,7 @@ InsertBufferLines(buf_T *buf, PyInt n, PyObject *lines, PyInt *len_change)
|
|||||||
appended_lines_mark((linenr_T)n, 1L);
|
appended_lines_mark((linenr_T)n, 1L);
|
||||||
|
|
||||||
vim_free(str);
|
vim_free(str);
|
||||||
restore_win_for_buf(save_curwin, save_curtab, &save_curbuf);
|
restore_win_for_buf(&switchwin, &save_curbuf);
|
||||||
update_screen(VALID);
|
update_screen(VALID);
|
||||||
|
|
||||||
if (VimTryEnd())
|
if (VimTryEnd())
|
||||||
@@ -4783,7 +4782,7 @@ InsertBufferLines(buf_T *buf, PyInt n, PyObject *lines, PyInt *len_change)
|
|||||||
|
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
VimTryStart();
|
VimTryStart();
|
||||||
switch_to_win_for_buf(buf, &save_curwin, &save_curtab, &save_curbuf);
|
switch_to_win_for_buf(buf, &switchwin, &save_curbuf);
|
||||||
|
|
||||||
if (u_save((linenr_T)n, (linenr_T)(n + 1)) == FAIL)
|
if (u_save((linenr_T)n, (linenr_T)(n + 1)) == FAIL)
|
||||||
RAISE_UNDO_FAIL;
|
RAISE_UNDO_FAIL;
|
||||||
@@ -4813,7 +4812,7 @@ InsertBufferLines(buf_T *buf, PyInt n, PyObject *lines, PyInt *len_change)
|
|||||||
// Free the array of lines. All of its contents have now
|
// Free the array of lines. All of its contents have now
|
||||||
// been freed.
|
// been freed.
|
||||||
PyMem_Free(array);
|
PyMem_Free(array);
|
||||||
restore_win_for_buf(save_curwin, save_curtab, &save_curbuf);
|
restore_win_for_buf(&switchwin, &save_curbuf);
|
||||||
|
|
||||||
update_screen(VALID);
|
update_screen(VALID);
|
||||||
|
|
||||||
|
@@ -21,6 +21,6 @@ void f_setbufline(typval_T *argvars, typval_T *rettv);
|
|||||||
void f_setline(typval_T *argvars, typval_T *rettv);
|
void f_setline(typval_T *argvars, typval_T *rettv);
|
||||||
void switch_buffer(bufref_T *save_curbuf, buf_T *buf);
|
void switch_buffer(bufref_T *save_curbuf, buf_T *buf);
|
||||||
void restore_buffer(bufref_T *save_curbuf);
|
void restore_buffer(bufref_T *save_curbuf);
|
||||||
void switch_to_win_for_buf(buf_T *buf, win_T **save_curwinp, tabpage_T **save_curtabp, bufref_T *save_curbuf);
|
void switch_to_win_for_buf(buf_T *buf, switchwin_T *switchwin, bufref_T *save_curbuf);
|
||||||
void restore_win_for_buf(win_T *save_curwin, tabpage_T *save_curtab, bufref_T *save_curbuf);
|
void restore_win_for_buf(switchwin_T *switchwin, bufref_T *save_curbuf);
|
||||||
/* vim: set ft=c : */
|
/* vim: set ft=c : */
|
||||||
|
@@ -32,8 +32,8 @@ void f_winrestcmd(typval_T *argvars, typval_T *rettv);
|
|||||||
void f_winrestview(typval_T *argvars, typval_T *rettv);
|
void f_winrestview(typval_T *argvars, typval_T *rettv);
|
||||||
void f_winsaveview(typval_T *argvars, typval_T *rettv);
|
void f_winsaveview(typval_T *argvars, typval_T *rettv);
|
||||||
void f_winwidth(typval_T *argvars, typval_T *rettv);
|
void f_winwidth(typval_T *argvars, typval_T *rettv);
|
||||||
int switch_win(win_T **save_curwin, tabpage_T **save_curtab, win_T *win, tabpage_T *tp, int no_display);
|
int switch_win(switchwin_T *switchwin, win_T *win, tabpage_T *tp, int no_display);
|
||||||
int switch_win_noblock(win_T **save_curwin, tabpage_T **save_curtab, win_T *win, tabpage_T *tp, int no_display);
|
int switch_win_noblock(switchwin_T *switchwin, win_T *win, tabpage_T *tp, int no_display);
|
||||||
void restore_win(win_T *save_curwin, tabpage_T *save_curtab, int no_display);
|
void restore_win(switchwin_T *switchwin, int no_display);
|
||||||
void restore_win_noblock(win_T *save_curwin, tabpage_T *save_curtab, int no_display);
|
void restore_win_noblock(switchwin_T *switchwin, int no_display);
|
||||||
/* vim: set ft=c : */
|
/* vim: set ft=c : */
|
||||||
|
@@ -4507,3 +4507,10 @@ typedef enum {
|
|||||||
FILTERMAP_MAPNEW
|
FILTERMAP_MAPNEW
|
||||||
} filtermap_T;
|
} filtermap_T;
|
||||||
|
|
||||||
|
// Structure used by switch_win() to pass values to restore_win()
|
||||||
|
typedef struct {
|
||||||
|
win_T *sw_curwin;
|
||||||
|
tabpage_T *sw_curtab;
|
||||||
|
int sw_same_win; // VIsual_active was not reset
|
||||||
|
int sw_visual_active;
|
||||||
|
} switchwin_T;
|
||||||
|
@@ -149,6 +149,16 @@ func Test_win_execute_other_tab()
|
|||||||
unlet xyz
|
unlet xyz
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_win_execute_visual_redraw()
|
||||||
|
call setline(1, ['a', 'b', 'c'])
|
||||||
|
new
|
||||||
|
wincmd p
|
||||||
|
call feedkeys("G\<C-V>", 'txn')
|
||||||
|
call win_execute(winnr('#')->win_getid(), 'redraw')
|
||||||
|
bwipe!
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_win_execute_on_startup()
|
func Test_win_execute_on_startup()
|
||||||
CheckRunVimInTerminal
|
CheckRunVimInTerminal
|
||||||
|
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4018,
|
||||||
/**/
|
/**/
|
||||||
4017,
|
4017,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user