diff --git a/kitty/file_transmission.py b/kitty/file_transmission.py index cef518834..9cead0df2 100644 --- a/kitty/file_transmission.py +++ b/kitty/file_transmission.py @@ -1058,13 +1058,14 @@ class FileTransmission: 'The remote machine wants to read some files from this computer. Do you want to allow the transfer?' )], window=window, custom_callback=partial(self.handle_receive_confirmation, asd_id), + default_data={'response': 'n'} ) def handle_receive_confirmation(self, cmd_id: str, data: Dict[str, str], *a: Any) -> None: asd = self.active_sends.get(cmd_id) if asd is None: return - if data['response'] == 'y': + if data.get('response') == 'y': asd.accepted = True else: self.drop_send(asd.id) @@ -1089,13 +1090,14 @@ class FileTransmission: 'The remote machine wants to send some files to this computer. Do you want to allow the transfer?' )], window=window, custom_callback=partial(self.handle_send_confirmation, ar_id), + default_data={'response': 'n'} ) def handle_send_confirmation(self, cmd_id: str, data: Dict[str, str], *a: Any) -> None: ar = self.active_receives.get(cmd_id) if ar is None: return - if data['response'] == 'y': + if data.get('response') == 'y': ar.accepted = True else: self.drop_receive(ar.id) diff --git a/kitty/window.py b/kitty/window.py index 9554ae9b0..dfd39b5ee 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -659,13 +659,14 @@ class Window: '--choice=o:Open', '--choice=c:Copy to clipboard', '--choice=n;red:Nothing' ], window=self, - custom_callback=partial(self.hyperlink_open_confirmed, url, cwd) + custom_callback=partial(self.hyperlink_open_confirmed, url, cwd), + default_data={'response': ''} ) return get_boss().open_url(url, cwd=cwd) def hyperlink_open_confirmed(self, url: str, cwd: Optional[str], data: Dict[str, Any], *a: Any) -> None: - q = data['response'] + q = data.get('response', '') if q == 'o': get_boss().open_url(url, cwd=cwd) elif q == 'c': @@ -912,14 +913,15 @@ class Window: 'A program running in this window wants to read from the system clipboard.' ' Allow it do so, once?')], window=self, - custom_callback=self.handle_clipboard_confirmation + custom_callback=self.handle_clipboard_confirmation, + default_data={'response': 'n'} ) def handle_clipboard_confirmation(self, data: Dict[str, Any], *a: Any) -> None: try: loc = 'p' if self.current_clipboard_read_ask else 'c' response = '' - if data['response'] == 'y': + if data.get('response') == 'y': response = get_primary_selection() if self.current_clipboard_read_ask else get_clipboard_string() self.send_osc52(loc, response) finally: