edit-in-kitty: Warn if SSH connection has dropped when attempting to update remote file

This commit is contained in:
newwares 2026-02-07 20:09:52 -05:00
parent 9aab18d724
commit 60e2d61eb4

View file

@ -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