diff --git a/kitty/boss.py b/kitty/boss.py index 1cc964b20..c5ea676bb 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -3131,10 +3131,10 @@ def _move_window_to( self._cleanup_tab_after_window_removal(src_tab) target_tab.make_active() - def _move_tab_to(self, tab: Tab | None = None, target_os_window_id: int | None = None) -> None: + def _move_tab_to(self, tab: Tab | None = None, target_os_window_id: int | None = None) -> Tab | None: tab = tab or self.active_tab if tab is None: - return + return None if target_os_window_id is None: target_os_window_id = self.add_os_window() tm = self.os_window_map[target_os_window_id] @@ -3142,6 +3142,7 @@ def _move_tab_to(self, tab: Tab | None = None, target_os_window_id: int | None = target_tab.take_over_from(tab) self._cleanup_tab_after_window_removal(tab) target_tab.make_active() + return target_tab def choose_entry( self, title: str, entries: Iterable[tuple[_T | str | None, str]], @@ -3265,7 +3266,8 @@ def chosen(ans: None | str | int) -> None: ''') def detach_tab(self, *args: str) -> None: if not args or args[0] == 'new': - return self._move_tab_to() + self._move_tab_to() + return items: list[tuple[str | int, str]] = [] ct = self.active_tab_manager_with_dispatch diff --git a/kitty/tabs.py b/kitty/tabs.py index 64bb31f90..37d5d1635 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -1613,8 +1613,13 @@ def on_tab_drop(self, x: int, y: int) -> None: return self.tab_being_dropped = None atid = self.active_tab.id if self.active_tab else 0 + set_tab_being_dragged() if tab.os_window_id != self.os_window_id: - get_boss()._move_tab_to(tab, self.os_window_id) + if (t := get_boss()._move_tab_to(tab, self.os_window_id)) is not None: + n = list(td.tab_ids) + idx = n.index(td.data.tab_id) + n[idx] = t.id + td = td._replace(tab_ids=n) self.apply_tab_ordering(td.tab_ids) if atid and tab.os_window_id == self.os_window_id and (tab := self.tab_for_id(atid)): idx = self.tabs.index(tab)