save_as_session: Show an error when the path is a directory

This commit is contained in:
Artem Lytkin 2026-09-23 21:58:06 +03:00
parent 259319c209
commit 62e5f48683
2 changed files with 6 additions and 0 deletions

View file

@ -217,6 +217,9 @@ Detailed list of changes
- Fix a packaging bug that could cause pipeline files to be omitted from some
kitty builds
- :ac:`save_as_session`: Show an error instead of saving next to the directory
when the specified path is an existing directory (:iss:`10520`)
0.49.0 [2026-09-21]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -701,6 +701,9 @@ def save_as_session_part2(boss: BossType, opts: SaveAsSessionOptions, path: str,
base_dir = os.path.abspath(os.path.expanduser(opts.base_dir))
path = os.path.join(base_dir, path)
path = os.path.abspath(os.path.expanduser(path))
if os.path.isdir(path):
boss.show_error(_('Invalid session path'), _('{} is a directory, specify a file name for the session').format(path))
return
if path_input_by_user and '.' not in os.path.basename(path):
path += '.kitty-session'
session = '\n'.join(boss.serialize_state_as_session(path, opts))