aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/winfloat.c
diff options
context:
space:
mode:
authorWill Hopkins <willothyh@gmail.com>2024-04-24 18:14:05 -0700
committerGitHub <noreply@github.com>2024-04-25 09:14:05 +0800
commit16513b30337523dc64707309ee7fe3dd2247266d (patch)
tree634b79f4f01d2ef7e6c0d2ec5c6c2d88b09aa745 /src/nvim/winfloat.c
parentc32fcd1ed527236e52cfd78033685e713ec36d75 (diff)
downloadrneovim-16513b30337523dc64707309ee7fe3dd2247266d.tar.gz
rneovim-16513b30337523dc64707309ee7fe3dd2247266d.tar.bz2
rneovim-16513b30337523dc64707309ee7fe3dd2247266d.zip
feat(api): allow floats to be opened in non-current tabpage (#28480)
\
Diffstat (limited to 'src/nvim/winfloat.c')
-rw-r--r--src/nvim/winfloat.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/nvim/winfloat.c b/src/nvim/winfloat.c
index f271f7d055..a0f426e30d 100644
--- a/src/nvim/winfloat.c
+++ b/src/nvim/winfloat.c
@@ -41,7 +41,24 @@
win_T *win_new_float(win_T *wp, bool last, WinConfig fconfig, Error *err)
{
if (wp == NULL) {
- wp = win_alloc(last ? lastwin : lastwin_nofloating(), false);
+ tabpage_T *tp = NULL;
+ win_T *tp_last = last ? lastwin : lastwin_nofloating();
+ if (fconfig.window != 0) {
+ assert(!last);
+ win_T *parent_wp = find_window_by_handle(fconfig.window, err);
+ if (!parent_wp) {
+ return NULL;
+ }
+ tp = win_find_tabpage(parent_wp);
+ if (!tp) {
+ return NULL;
+ }
+ tp_last = tp->tp_lastwin;
+ while (tp_last->w_floating && tp_last->w_prev) {
+ tp_last = tp_last->w_prev;
+ }
+ }
+ wp = win_alloc(tp_last, false);
win_init(wp, curwin, 0);
} else {
assert(!last);