From 719849f4fc62d8a08f6ce96138f9465fb05572d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=B8=BD?= <18717730+xiaobai050@users.noreply.github.com> Date: Sat, 26 Sep 2026 19:06:18 +0800 Subject: [PATCH] Fix tab hover switching during tab drags Window drop previews are cleared before tab drop previews on each tab drag update. With the shared hover state, this cancels the tab hover timer on every update, preventing the 0.6 second tab switch. Preserve a tab hover timer when clearing a window drop preview. Keep the existing cancellation behavior for window drags and cover the regression. --- kitty/tabs.py | 5 ++++- kitty_tests/tab_drop.py | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/kitty/tabs.py b/kitty/tabs.py index 4f9b5f0bc..eae562067 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -2098,7 +2098,10 @@ class TabManager: # {{{ tab_id = target.tab_id if target is not None else 0 # Highlight the "+" button only when appending, elsewhere the insertion marker is enough self._set_drag_target_tab(-1 if before == 0 else tab_id) - self._update_drag_hover(tab_id, window_id, source_is_window=True) + # Tab drags clear the window preview before updating the tab preview on + # every drag event. Keep an existing tab hover timer across those events. + if tab_id or self.drag_hover is None or self.drag_hover.source_is_window: + self._update_drag_hover(tab_id, window_id, source_is_window=True) def _clear_force_show_title_bars(self) -> None: boss = get_boss() diff --git a/kitty_tests/tab_drop.py b/kitty_tests/tab_drop.py index 581bc060b..94f4112b4 100644 --- a/kitty_tests/tab_drop.py +++ b/kitty_tests/tab_drop.py @@ -593,6 +593,15 @@ class TestWindowDropTabs(BaseTest): self.hover() self.ae(self.add_timer.call_count, 1) + def test_clearing_window_preview_preserves_tab_hover(self): + self.tm._update_drag_hover(2, 9, source_is_window=False) + hover = self.tm.drag_hover + for _ in range(3): + self.tm._set_window_drop_tab_target() + self.assertIs(self.tm.drag_hover, hover) + self.add_timer.assert_called_once() + self.remove_timer.assert_not_called() + def test_changing_targets_restarts_hover_and_ignores_stale_timer(self): self.hover() first_callback = self.add_timer.call_args.args[0]