Fix dropping of tab into other os window breaking tab bar layout
This commit is contained in:
parent
0682c5bc8a
commit
e10451dbcb
2 changed files with 11 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue