mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Fix test failure with fish >= 4.1
fish now requires a response to a DA1 query
This commit is contained in:
@@ -138,7 +138,10 @@ class Callbacks:
|
||||
self.bell_count += 1
|
||||
|
||||
def on_da1(self) -> None:
|
||||
self.da1.append(da1(get_options()))
|
||||
payload = da1(get_options())
|
||||
self.da1.append(payload)
|
||||
if self.pty and self.pty.needs_da1:
|
||||
self.pty.send_da1_response(payload)
|
||||
|
||||
def on_activity_since_last_focus(self) -> None:
|
||||
pass
|
||||
@@ -279,10 +282,13 @@ class BaseTest(TestCase):
|
||||
|
||||
def create_pty(
|
||||
self, argv=None, cols=80, lines=100, scrollback=100, cell_width=10, cell_height=20,
|
||||
options=None, cwd=None, env=None, stdin_fd=None, stdout_fd=None
|
||||
options=None, cwd=None, env=None, stdin_fd=None, stdout_fd=None, needs_da1=False,
|
||||
):
|
||||
self.set_options(options)
|
||||
return PTY(argv, lines, cols, scrollback, cell_width, cell_height, cwd, env, stdin_fd=stdin_fd, stdout_fd=stdout_fd)
|
||||
return PTY(
|
||||
argv, lines, cols, scrollback, cell_width, cell_height, cwd, env, stdin_fd=stdin_fd, stdout_fd=stdout_fd,
|
||||
needs_da1=needs_da1,
|
||||
)
|
||||
|
||||
def assertEqualAttributes(self, c1, c2):
|
||||
x1, y1, c1.x, c1.y = c1.x, c1.y, 0, 0
|
||||
@@ -315,7 +321,7 @@ class PTY:
|
||||
|
||||
def __init__(
|
||||
self, argv=None, rows=25, columns=80, scrollback=100, cell_width=10, cell_height=20,
|
||||
cwd=None, env=None, stdin_fd=None, stdout_fd=None
|
||||
cwd=None, env=None, stdin_fd=None, stdout_fd=None, needs_da1=False,
|
||||
):
|
||||
self.is_child = False
|
||||
if isinstance(argv, str):
|
||||
@@ -353,6 +359,7 @@ class PTY:
|
||||
self.cell_width = cell_width
|
||||
self.cell_height = cell_height
|
||||
self.set_window_size(rows=rows, columns=columns)
|
||||
self.needs_da1 = needs_da1
|
||||
self.callbacks = Callbacks(self)
|
||||
self.screen = Screen(self.callbacks, rows, columns, scrollback, cell_width, cell_height, 0, self.callbacks)
|
||||
self.received_bytes = b''
|
||||
@@ -385,6 +392,9 @@ class PTY:
|
||||
if flush:
|
||||
self.process_input_from_child(0)
|
||||
|
||||
def send_da1_response(self, data: str) -> None:
|
||||
self.write_to_child('\x1b[' + data, flush=True)
|
||||
|
||||
def send_cmd_to_child(self, cmd, flush=False):
|
||||
self.callbacks.last_cmd_exit_status = sys.maxsize
|
||||
self.last_cmd = cmd
|
||||
|
||||
@@ -88,6 +88,7 @@ class ShellIntegration(BaseTest):
|
||||
@contextmanager
|
||||
def run_shell(self, shell='zsh', rc='', cmd='', setup_env=None, extra_env=None):
|
||||
home_dir = self.home_dir = os.path.realpath(tempfile.mkdtemp())
|
||||
needs_da1 = os.path.basename(shell) == 'fish'
|
||||
cmd = cmd or shell
|
||||
cmd = shlex.split(cmd.format(**locals()))
|
||||
env = (setup_env or safe_env_for_running_shell)(cmd, home_dir, rc=rc, shell=shell, with_kitten=self.with_kitten)
|
||||
@@ -97,7 +98,7 @@ class ShellIntegration(BaseTest):
|
||||
try:
|
||||
if self.with_kitten:
|
||||
cmd = [kitten_exe(), 'run-shell', '--shell', shlex.join(cmd)]
|
||||
pty = self.create_pty(cmd, cwd=home_dir, env=env, cols=180)
|
||||
pty = self.create_pty(cmd, cwd=home_dir, env=env, cols=180, needs_da1=needs_da1)
|
||||
i = 10
|
||||
while i > 0 and not pty.screen_contents().strip():
|
||||
pty.process_input_from_child()
|
||||
|
||||
Reference in New Issue
Block a user