diff --git a/docs/changelog.rst b/docs/changelog.rst index c0f0e1a5c..0f1db38d8 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -49,6 +49,8 @@ Detailed list of changes - macOS: Remote control: Fix unable to launch a new OS window or background process when there is no OS window (:iss:`5210`) +- macOS: Fix unable to open new tab or new window when there is no OS window (:iss:`5276`) + - kitty @ set-colors: Fix changing inactive_tab_foreground not working (:iss:`5214`) - macOS: Fix a regression that caused switching keyboard input using Eisu and diff --git a/kitty/boss.py b/kitty/boss.py index 73b68020e..423008535 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1812,6 +1812,8 @@ class Boss: special_window = args else: special_window = self.args_to_special_window(args, cwd_from=cwd_from) + if not self.os_window_map: + self.add_os_window() tm = self.active_tab_manager if tm is not None: return tm.new_tab(special_window=special_window, cwd_from=cwd_from, as_neighbor=as_neighbor) @@ -1833,8 +1835,6 @@ class Boss: self._create_tab(list(args), cwd_from=CwdRequest(self.active_window_for_cwd)) def new_tab_with_wd(self, wd: Union[str, List[str]], str_is_multiple_paths: bool = False) -> None: - if not self.os_window_map: - self.add_os_window() if isinstance(wd, str): wd = wd.split(os.pathsep) if str_is_multiple_paths else [wd] for path in wd: @@ -1842,6 +1842,11 @@ class Boss: self._new_tab(special_window) def _new_window(self, args: List[str], cwd_from: Optional[CwdRequest] = None) -> Optional[Window]: + if not self.os_window_map: + os_window_id = self.add_os_window() + tm = self.os_window_map.get(os_window_id) + if tm is not None and not tm.active_tab: + tm.new_tab(empty_tab=True) tab = self.active_tab if tab is None: return None diff --git a/kitty/rc/launch.py b/kitty/rc/launch.py index d19da9cd2..022037df6 100644 --- a/kitty/rc/launch.py +++ b/kitty/rc/launch.py @@ -85,7 +85,7 @@ instead of the active tab tabs = self.tabs_for_match_payload(boss, window, payload_get) if tabs and tabs[0]: target_tab = tabs[0] - elif payload_get('type') not in ('os-window', 'background'): + elif payload_get('type') not in ('background', 'os-window', 'tab', 'window'): return None w = do_launch(boss, opts, payload_get('args') or [], target_tab=target_tab) return None if payload_get('no_response') else str(getattr(w, 'id', 0))