macOS: Fix unable to open new tab/window when there is no OS window

This commit is contained in:
pagedown 2022-07-14 18:25:00 +08:00
parent b0666c9180
commit 512db660a1
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB
3 changed files with 10 additions and 3 deletions

View File

@ -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: 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`) - kitty @ set-colors: Fix changing inactive_tab_foreground not working (:iss:`5214`)
- macOS: Fix a regression that caused switching keyboard input using Eisu and - macOS: Fix a regression that caused switching keyboard input using Eisu and

View File

@ -1812,6 +1812,8 @@ class Boss:
special_window = args special_window = args
else: else:
special_window = self.args_to_special_window(args, cwd_from=cwd_from) 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 tm = self.active_tab_manager
if tm is not None: if tm is not None:
return tm.new_tab(special_window=special_window, cwd_from=cwd_from, as_neighbor=as_neighbor) 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)) 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: 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): if isinstance(wd, str):
wd = wd.split(os.pathsep) if str_is_multiple_paths else [wd] wd = wd.split(os.pathsep) if str_is_multiple_paths else [wd]
for path in wd: for path in wd:
@ -1842,6 +1842,11 @@ class Boss:
self._new_tab(special_window) self._new_tab(special_window)
def _new_window(self, args: List[str], cwd_from: Optional[CwdRequest] = None) -> Optional[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 tab = self.active_tab
if tab is None: if tab is None:
return None return None

View File

@ -85,7 +85,7 @@ instead of the active tab
tabs = self.tabs_for_match_payload(boss, window, payload_get) tabs = self.tabs_for_match_payload(boss, window, payload_get)
if tabs and tabs[0]: if tabs and tabs[0]:
target_tab = 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 return None
w = do_launch(boss, opts, payload_get('args') or [], target_tab=target_tab) 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)) return None if payload_get('no_response') else str(getattr(w, 'id', 0))