This commit is contained in:
Kovid Goyal
2025-08-15 20:19:28 +05:30
parent 8702057dda
commit 7b1647a5f7

View File

@@ -8,6 +8,7 @@ import shutil
import sys
from collections.abc import Generator, Sequence
from contextlib import contextmanager, suppress
from gettext import gettext as _
from .borders import load_borders_program
from .boss import Boss
@@ -281,7 +282,14 @@ def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = (),
pos_x, pos_y = cached_values.get('window-pos', (None, None))
if args.position:
pos_x, pos_y = map(int, args.position.lower().partition('x')[::2])
startup_sessions = tuple(create_sessions(opts, args, default_session=opts.startup_session))
startup_session_error: tuple[Exception, str] | None = None
try:
startup_sessions = tuple(create_sessions(opts, args, default_session=opts.startup_session))
except Exception as e:
startup_session_error = (e, (getattr(args, 'session', '') or opts.startup_session or ''))
if getattr(args, 'session', ''):
args.session = ''
startup_sessions = tuple(create_sessions(opts, args))
wincls = (startup_sessions[0].os_window_class if startup_sessions else '') or args.cls or appname
winname = (startup_sessions[0].os_window_name if startup_sessions else '') or args.name or wincls or appname
window_state = (args.start_as if args.start_as and args.start_as != 'normal' else None) or (
@@ -302,6 +310,9 @@ def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = (),
if bad_lines or boss.misc_config_errors:
boss.show_bad_config_lines(bad_lines, boss.misc_config_errors)
boss.misc_config_errors = []
if startup_session_error:
boss.show_error(_('The startup session was invalid'), _(
'Loading the start session file {0} failed, with error:\n{1}').format(startup_session_error[1], startup_session_error[0]))
try:
boss.child_monitor.main_loop()
finally: