diff --git a/kitty/launch.py b/kitty/launch.py index cc4ab21cf..2ba0088ff 100644 --- a/kitty/launch.py +++ b/kitty/launch.py @@ -520,14 +520,14 @@ class CloneCmd: if k == 'a': self.args.append(v) elif k == 'env': - env = {} + self.env = {} for line in v.split('\0'): if line: try: k, v = line.split('=', 1) except ValueError: continue - env[k] = v + self.env[k] = v elif k == 'cwd': self.cwd = v elif k == 'argv': diff --git a/kitty_tests/__init__.py b/kitty_tests/__init__.py index 39f8aa9a3..c4270162e 100644 --- a/kitty_tests/__init__.py +++ b/kitty_tests/__init__.py @@ -71,6 +71,8 @@ class Callbacks: self.open_urls = [] self.cc_buf = [] self.bell_count = 0 + self.clone_cmds = [] + self.current_clone_data = '' def on_bell(self) -> None: self.bell_count += 1 @@ -94,6 +96,19 @@ class Callbacks: text = process_remote_print(msg) print(text, file=sys.__stderr__) + def handle_remote_clone(self, msg): + if not msg: + if self.current_clone_data: + cdata, self.current_clone_data = self.current_clone_data, '' + from kitty.launch import CloneCmd + self.clone_cmds.append(CloneCmd(cdata)) + self.current_clone_data = '' + return + num, rest = msg.split(':', 1) + if num == '0' or len(self.current_clone_data) > 1024 * 1024: + self.current_clone_data = '' + self.current_clone_data += rest + def handle_remote_ssh(self, msg): from kittens.ssh.main import get_ssh_data if self.pty: diff --git a/kitty_tests/shell_integration.py b/kitty_tests/shell_integration.py index 54fcb85f8..d5fe1a8d9 100644 --- a/kitty_tests/shell_integration.py +++ b/kitty_tests/shell_integration.py @@ -148,6 +148,12 @@ RPS1="{rps1}" os.mkdir(q) pty.send_cmd_to_child(f'cd {q}') pty.wait_till(lambda: pty.screen.last_reported_cwd.endswith(q)) + with self.run_shell(rc=f'''PS1="{ps1}"\nexport ES="a\n b c\nd"''') as pty: + pty.callbacks.clear() + pty.send_cmd_to_child('clone-in-kitty') + pty.wait_till(lambda: len(pty.callbacks.clone_cmds) == 1) + env = pty.callbacks.clone_cmds[0].env + self.ae(env.get('ES'), 'a\n b c\nd') @unittest.skipUnless(shutil.which('fish'), 'fish not installed') def test_fish_integration(self):