From 79a780004faef3f9087a76c3e47b8d29a8571473 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 May 2020 17:08:46 +0530 Subject: [PATCH] Remove references to overlay_for from boss --- kitty/boss.py | 15 +++++++-------- kitty/tabs.py | 4 ++++ kitty/window_list.py | 8 ++++++++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/kitty/boss.py b/kitty/boss.py index 8af397550..827f02bb8 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -304,10 +304,9 @@ class Boss: @property def active_window_for_cwd(self) -> Optional[Window]: - w = self.active_window - if w is not None and w.overlay_for is not None and w.overlay_for in self.window_id_map: - w = self.window_id_map[w.overlay_for] - return w + t = self.active_tab + if t is not None: + return t.active_window_for_cwd def new_os_window_with_cwd(self, *args: str) -> None: w = self.active_window_for_cwd @@ -752,7 +751,7 @@ class Boss: def display_scrollback(self, window: Window, data: Optional[bytes], cmd: Optional[List[str]]) -> None: tab = self.active_tab - if tab is not None and window.overlay_for is None: + if tab is not None: tab.new_special_window( SpecialWindow(cmd, data, _('History'), overlay_for=window.id), copy_colors_from=self.active_window @@ -795,7 +794,7 @@ class Boss: if end_kitten.no_ui: return end_kitten(None, getattr(w, 'id', None), self) - if w is not None and tab is not None and w.overlay_for is None: + if w is not None and tab is not None: args[0:0] = [config_dir, kitten] if input_data is None: type_of_input = end_kitten.type_of_input @@ -905,7 +904,7 @@ class Boss: elif window_type == 'overlay': w = self.active_window tab = self.active_tab - if w is not None and tab is not None and w.overlay_for is None: + if w is not None and tab is not None: tab.new_special_window(SpecialWindow(cmd, overlay_for=w.id)) else: self._new_window(cmd) @@ -1047,7 +1046,7 @@ class Boss: continue arg = q cmdline.append(arg) - overlay_for = w.id if w and as_overlay and w.overlay_for is None else None + overlay_for = w.id if w and as_overlay else None return SpecialWindow(cmd, input_data, cwd_from=cwd_from, overlay_for=overlay_for, env=env) def run_background_process( diff --git a/kitty/tabs.py b/kitty/tabs.py index 98fa55c15..3bd4d34ae 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -167,6 +167,10 @@ class Tab: # {{{ def active_window(self) -> Optional[Window]: return self.windows.active_window + @property + def active_window_for_cwd(self) -> Optional[Window]: + return self.windows.active_group_base + @property def title(self) -> str: return cast(str, getattr(self.active_window, 'title', appname)) diff --git a/kitty/window_list.py b/kitty/window_list.py index 5fea514ad..58810b1fb 100644 --- a/kitty/window_list.py +++ b/kitty/window_list.py @@ -191,6 +191,14 @@ class WindowList: pass return None + @property + def active_group_base(self) -> Optional[WindowType]: + try: + return self.id_map[self.groups[self.active_group_idx].base_window_id] + except IndexError: + pass + return None + def set_active_window_group_for(self, x: WindowOrId) -> None: q = self.id_map[x] if isinstance(x, int) else x for i, group in enumerate(self.groups):