From 60e2d61eb47a150236d8ba9eea5b7f39915f225f Mon Sep 17 00:00:00 2001 From: newwares <45801973+waresnew@users.noreply.github.com> Date: Sat, 7 Feb 2026 20:09:52 -0500 Subject: [PATCH] edit-in-kitty: Warn if SSH connection has dropped when attempting to update remote file --- kitty/launch.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kitty/launch.py b/kitty/launch.py index 233fedf54..167e55e01 100644 --- a/kitty/launch.py +++ b/kitty/launch.py @@ -962,8 +962,9 @@ def __init__(self, msg: str) -> None: def __del__(self) -> None: if self.tdir: - with suppress(OSError): - shutil.rmtree(self.tdir) + if not self.abort_signaled == 'disconnected': + with suppress(OSError): + shutil.rmtree(self.tdir) self.tdir = '' def read_data(self) -> bytes: @@ -1002,6 +1003,12 @@ def check_status(self, timer_id: int | None = None) -> None: self.schedule_check() def send_data(self, window: Window, data_type: str, data: bytes = b'') -> None: + if not self.is_local_file and not window.child_is_remote: + self.abort_signaled = 'disconnected' + get_boss().show_error( + 'edit-in-kitty', f'Failed to sync file due to the SSH connection dropping. Your local changes can still be found at {self.file_localpath}' + ) + return window.write_to_child(f'KITTY_DATA_START\n{data_type}\n') if data: import base64