summaryrefslogtreecommitdiffstats
path: root/src/popupwin.c
diff options
context:
space:
mode:
authorChristian Brabandt <cb@256bit.org>2024-06-18 20:50:58 +0200
committerChristian Brabandt <cb@256bit.org>2024-06-18 21:01:23 +0200
commitfbc37f138a5d70f1b212b9de9959a0816481edcf (patch)
tree17f8ace4a09dd5054c82e6f38491d3e2e0a7f0ca /src/popupwin.c
parent23c5ebeb95cb942df307946e3ced230a7c8312eb (diff)
patch 9.1.0500: cannot switch buffer in a popupv9.1.0500
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>
Diffstat (limited to 'src/popupwin.c')
-rw-r--r--src/popupwin.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index 38c1c9e0d0..e35327217e 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -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)
{