Fix launch command not creating a new window if no OS window is present
This commit is contained in:
parent
1358f00969
commit
a2269cb66e
@ -11,7 +11,7 @@ from .cli_stub import LaunchCLIOptions
|
|||||||
from .constants import kitty_exe, shell_path
|
from .constants import kitty_exe, shell_path
|
||||||
from .fast_data_types import patch_color_profiles, set_clipboard_string
|
from .fast_data_types import patch_color_profiles, set_clipboard_string
|
||||||
from .options.utils import env as parse_env
|
from .options.utils import env as parse_env
|
||||||
from .tabs import Tab
|
from .tabs import Tab, TabManager
|
||||||
from .types import run_once
|
from .types import run_once
|
||||||
from .utils import log_error, resolve_custom_file, set_primary_selection, which
|
from .utils import log_error, resolve_custom_file, set_primary_selection, which
|
||||||
from .window import Watchers, Window
|
from .window import Watchers, Window
|
||||||
@ -227,25 +227,26 @@ def get_env(opts: LaunchCLIOptions, active_child: Optional[Child]) -> Dict[str,
|
|||||||
|
|
||||||
|
|
||||||
def tab_for_window(boss: Boss, opts: LaunchCLIOptions, target_tab: Optional[Tab] = None) -> Optional[Tab]:
|
def tab_for_window(boss: Boss, opts: LaunchCLIOptions, target_tab: Optional[Tab] = None) -> Optional[Tab]:
|
||||||
|
|
||||||
|
def create_tab(tm: Optional[TabManager] = None) -> Tab:
|
||||||
|
if tm is None:
|
||||||
|
oswid = boss.add_os_window(wclass=opts.os_window_class, wname=opts.os_window_name, override_title=opts.os_window_title or None)
|
||||||
|
tm = boss.os_window_map[oswid]
|
||||||
|
tab = tm.new_tab(empty_tab=True, location=opts.location)
|
||||||
|
if opts.tab_title:
|
||||||
|
tab.set_title(opts.tab_title)
|
||||||
|
return tab
|
||||||
|
|
||||||
if opts.type == 'tab':
|
if opts.type == 'tab':
|
||||||
if target_tab is not None:
|
if target_tab is not None:
|
||||||
tm = target_tab.tab_manager_ref() or boss.active_tab_manager
|
tm = target_tab.tab_manager_ref() or boss.active_tab_manager
|
||||||
else:
|
else:
|
||||||
tm = boss.active_tab_manager
|
tm = boss.active_tab_manager
|
||||||
if tm:
|
tab = create_tab(tm)
|
||||||
tab: Optional[Tab] = tm.new_tab(empty_tab=True, location=opts.location)
|
|
||||||
if opts.tab_title and tab is not None:
|
|
||||||
tab.set_title(opts.tab_title)
|
|
||||||
else:
|
|
||||||
tab = None
|
|
||||||
elif opts.type == 'os-window':
|
elif opts.type == 'os-window':
|
||||||
oswid = boss.add_os_window(wclass=opts.os_window_class, wname=opts.os_window_name, override_title=opts.os_window_title or None)
|
tab = create_tab()
|
||||||
tm = boss.os_window_map[oswid]
|
|
||||||
tab = tm.new_tab(empty_tab=True)
|
|
||||||
if opts.tab_title and tab is not None:
|
|
||||||
tab.set_title(opts.tab_title)
|
|
||||||
else:
|
else:
|
||||||
tab = target_tab or boss.active_tab
|
tab = target_tab or boss.active_tab or create_tab()
|
||||||
|
|
||||||
return tab
|
return tab
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user