0
0
mirror of https://github.com/vim/vim.git synced 2025-10-29 09:37:35 -04:00

patch 9.1.0500: cannot switch buffer in a popup

Problem:  cannot switch buffer in a popup
          (Yggdroot)
Solution: add popup_setbuf() function

fixes: #15006
closes: #15026

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2024-06-18 20:50:58 +02:00
parent 23c5ebeb95
commit fbc37f138a
17 changed files with 224 additions and 7 deletions

View File

@@ -2844,6 +2844,54 @@ f_popup_settext(typval_T *argvars, typval_T *rettv UNUSED)
popup_adjust_position(wp);
}
/*
* popup_setbuf({id}, {bufnr})
*/
void
f_popup_setbuf(typval_T *argvars, typval_T *rettv UNUSED)
{
int id;
win_T *wp;
buf_T *buf;
rettv->v_type = VAR_BOOL;
rettv->vval.v_number = VVAL_FALSE;
if (check_for_number_arg(argvars, 0) == FAIL
|| check_for_buffer_arg(argvars, 1) == FAIL)
return;
id = (int)tv_get_number(&argvars[0]);
wp = find_popup_win(id);
if (wp == NULL)
return;
buf = tv_get_buf_from_arg(&argvars[1]);
if (buf == NULL)
return;
#ifdef FEAT_TERMINAL
if (buf->b_term != NULL && popup_terminal_exists())
{
emsg(_(e_cannot_open_second_popup_with_terminal));
return;
}
#endif
if (wp->w_buffer != buf)
{
wp->w_buffer->b_nwindows--;
win_init_popup_win(wp, buf);
set_local_options_default(wp, FALSE);
swap_exists_action = SEA_READONLY;
buffer_ensure_loaded(buf);
swap_exists_action = SEA_NONE;
redraw_win_later(wp, UPD_NOT_VALID);
popup_adjust_position(wp);
}
rettv->vval.v_number = VVAL_TRUE;
}
static void
popup_free(win_T *wp)
{