@@ -532,17 +532,19 @@ def all_windows(self) -> Iterator[Window]:
532532 for tab in self .all_tabs :
533533 yield from tab
534534
535- def match_windows (self , match : str , self_window : Optional ['Window' ] = None ) -> Iterator [Window ]:
535+ def match_windows (self , match : str , self_window : Optional ['Window' ] = None , all_windows : Iterable [Window ] | None = None ) -> Iterator [Window ]:
536+ all_windows = self .all_windows if all_windows is None else all_windows
536537 if match == 'all' :
537- yield from self . all_windows
538+ yield from all_windows
538539 return
539540 from .search_query_parser import search
540541 tab = self .active_tab
541542 if current_focused_os_window_id () <= 0 :
542543 tm = self .os_window_map .get (last_focused_os_window_id ())
543544 if tm is not None :
544545 tab = tm .active_tab
545- window_id_limit = max (self .window_id_map , default = - 1 ) + 1
546+ wids = {w .id for w in all_windows }
547+ window_id_limit = max (wids , default = - 1 ) + 1
546548 active_session = self .active_session
547549
548550 def get_matches (location : str , query : str , candidates : set [int ]) -> set [int ]:
@@ -557,25 +559,19 @@ def get_matches(location: str, query: str, candidates: set[int]) -> set[int]:
557559
558560 for wid in search (match , (
559561 'id' , 'title' , 'pid' , 'cwd' , 'cmdline' , 'num' , 'env' , 'var' , 'recent' , 'state' , 'neighbor' , 'session' ,
560- ), set ( self . window_id_map ) , get_matches ):
562+ ), wids , get_matches ):
561563 yield self .window_id_map [wid ]
562564
563- def tab_for_window (self , window : Window ) -> Tab | None :
564- for tab in self .all_tabs :
565- for w in tab :
566- if w .id == window .id :
567- return tab
568- return None
569-
570- def match_tabs (self , match : str ) -> Iterator [Tab ]:
565+ def match_tabs (self , match : str , all_tabs : Iterable [Tab ] | None = None ) -> Iterator [Tab ]:
566+ all_tabs = self .all_tabs if all_tabs is None else all_tabs
571567 if match == 'all' :
572- yield from self . all_tabs
568+ yield from all_tabs
573569 return
574570 from .search_query_parser import search
575571 tm = self .active_tab_manager
576572 if current_focused_os_window_id () <= 0 :
577573 tm = self .os_window_map .get (last_focused_os_window_id ()) or tm
578- tim = {t .id : t for t in self . all_tabs }
574+ tim = {t .id : t for t in all_tabs }
579575 tab_id_limit = max (tim , default = - 1 ) + 1
580576 window_id_limit = max (self .window_id_map , default = - 1 ) + 1
581577
@@ -592,13 +588,14 @@ def get_matches(location: str, query: str, candidates: set[int]) -> set[int]:
592588
593589 found = False
594590 for tid in search (match , (
595- 'id' , 'index' , 'title' , 'window_id' , 'window_title' , 'pid' , 'cwd' , 'env' , 'var' , 'cmdline' , 'recent' , 'state' , 'session' ,
591+ 'id' , 'index' , 'title' , 'window_id' , 'window_title' , 'pid' , 'cwd' , 'env' , 'var' ,
592+ 'cmdline' , 'recent' , 'state' , 'session' ,
596593 ), set (tim ), get_matches ):
597594 found = True
598595 yield tim [tid ]
599596
600597 if not found :
601- tabs = {self . tab_for_window ( w ) for w in self .match_windows (match )}
598+ tabs = {w . tabref ( ) for w in self .match_windows (match )}
602599 for q in tabs :
603600 if q :
604601 yield q
@@ -3007,7 +3004,7 @@ def _move_window_to(
30073004 window = window or self .active_window
30083005 if not window :
30093006 return
3010- src_tab = self . tab_for_window ( window )
3007+ src_tab = window . tabref ( )
30113008 if src_tab is None :
30123009 return
30133010 with self .suppress_focus_change_events ():
0 commit comments