mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-19 22:55:29 +00:00
Cleanup previous PR ensuring stale saved restore tabis not present
This commit is contained in:
parent
a893ed373c
commit
dfa9c097e2
2 changed files with 16 additions and 0 deletions
|
|
@ -1553,6 +1553,10 @@ class Boss:
|
|||
tm.handle_tab_bar_mouse(x, y, button, modifiers, action)
|
||||
|
||||
def start_tab_drag(self, os_window_id: int, window_id: int, pixels: bytes, width: int, height: int) -> None:
|
||||
# A previous drag whose drop never reached _reset_drop_previews (failed transfer, dragged
|
||||
# tab closed, etc.) can leave stale pre-hover focus behind, discard it.
|
||||
for q in self.all_tab_managers:
|
||||
q.finish_tab_drag_hover(restore_focus=False)
|
||||
if tm := self.os_window_map.get(os_window_id):
|
||||
tm.start_tab_drag(pixels, width, height)
|
||||
|
||||
|
|
|
|||
|
|
@ -144,6 +144,18 @@ class TestTabDropClassification(BossDropTest):
|
|||
self.tm.on_tab_drop.assert_called_once_with(600, 10)
|
||||
self.tm.finish_tab_drag_hover.assert_called_with(restore_focus=True)
|
||||
|
||||
def test_new_tab_drag_discards_stale_hover_focus(self):
|
||||
# A failed drop never reaches _reset_drop_previews, so the saved focus must not survive
|
||||
# into the next drag
|
||||
self.boss.show_error = Mock()
|
||||
Boss.on_drop(self.boss, 1, 5, True, 600, 10)
|
||||
self.boss.show_error.assert_called_once()
|
||||
self.tm.finish_tab_drag_hover.assert_not_called()
|
||||
self.tm.start_tab_drag = Mock()
|
||||
Boss.start_tab_drag(self.boss, 1, 0, b'', 0, 0)
|
||||
self.tm.finish_tab_drag_hover.assert_called_once_with(restore_focus=False)
|
||||
self.tm.start_tab_drag.assert_called_once_with(b'', 0, 0)
|
||||
|
||||
def test_cross_window_tab_bar_drop_keeps_destination_focus(self):
|
||||
self.source.os_window_id = 9
|
||||
self.ae(self.drop(600, 10), 'tab_drop')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue