From: Nicolas Peugnet <nicolas@club1.fr>
Date: Sun, 8 Mar 2026 14:09:15 +0100
Subject: Send clear command in two steps during tests
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

By first sending the "clear" text and waiting for it to appear of the
screen before sending "\n", we make sure that the following wait on a
new prompt is not the one before the "clear" text have been printed.

This should get rid of this kind of errors:

|   --- test/tests/tests.yaml	2026-03-05 10:01:20.000000000 +0000
|   +++ test/tests/tests.new.yaml	2026-03-08 09:57:11.046911186 +0000
|   @@ -44,6 +44,7 @@
|    bash_expected: |
|      > crazy-complete-test test
|    fish_expected: |
|   +  crazy-complete-test t	⏎
|      > crazy-complete-test test
|    zsh_expected: |
|      > crazy-complete-test test
|   @@ -808,6 +809,7 @@
|    bash_expected: |
|      > crazy-complete-test complete --value-list foo,
|    fish_expected: |
|   +  crazy-complete-test complete --value-list foo⏎
|      > crazy-complete-test complete --value-list foo
|    zsh_expected: |
|      > crazy-complete-test complete --value-list foo,
|   @@ -1546,6 +1548,7 @@
|      one    three  two
|      > crazy-complete-test --colon-list
|    fish_expected: |
|   +  crazy-complete-test --colon-list ⏎
|      > crazy-complete-test --colon-list
|      one  three  two
|    zsh_expected: |

We have to disable the "Autosuggestions" feature of fish, otherwise the
"clear" command gets automcompleted to something like this:
"> clear; source output/main.fish", which does not match the expected:
"> clear". This only changes the output of two tests.

Forwarded: https://github.com/crazy-complete/crazy-complete/pull/28
---
 test/tests/shells.py        | 2 +-
 test/tests/terminal_base.py | 4 +++-
 test/tests/tests.yaml       | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/test/tests/shells.py b/test/tests/shells.py
index c9d7c50..ca9459a 100644
--- a/test/tests/shells.py
+++ b/test/tests/shells.py
@@ -52,7 +52,7 @@ class BashShell(ShellBase):
 
 class FishShell(ShellBase):
     def start(self):
-        self.term.start(['fish', '--no-config'], SHELL_ENV)
+        self.term.start(['fish', '--no-config'], SHELL_ENV | {'fish_autosuggestion_enabled': 0})
 
     def set_prompt(self):
         self.term.send_line("clear; function fish_prompt; printf '> '; end")
diff --git a/test/tests/terminal_base.py b/test/tests/terminal_base.py
index 06e852a..3f8c5b3 100644
--- a/test/tests/terminal_base.py
+++ b/test/tests/terminal_base.py
@@ -15,7 +15,9 @@ class TerminalBase:
             # Clear current command line, as fish does not do it on ^C
             self.send_ctrl("u")
             self.wait_for_last_line('>', 5, 0.01)
-            self.send_line('clear')
+            self.send('clear')
+            self.wait_for_last_line('> clear', 5, 0.01)
+            self.send_line('')
             result = self.wait_for_text('>', 5, 0.01)
 
     def complete(self, commandline, num_tabs=1, wait=5, expected=None, fast=False):
diff --git a/test/tests/tests.yaml b/test/tests/tests.yaml
index 98f8db0..d316aa3 100644
--- a/test/tests/tests.yaml
+++ b/test/tests/tests.yaml
@@ -1097,7 +1097,7 @@ bash_expected: |
   --option=   --sub-bar=
   > crazy-complete-test subcommand --
 fish_expected: |
-  > crazy-complete-test subcommand --option
+  > crazy-complete-test subcommand --
   --option  --sub-bar
 zsh_expected: |
   > crazy-complete-test subcommand --
@@ -1112,7 +1112,7 @@ bash_expected: |
   --option=   --sub-bar=
   > crazy-complete-test subcommand --option lastcommand --
 fish_expected: |
-  > crazy-complete-test subcommand --option lastcommand --option
+  > crazy-complete-test subcommand --option lastcommand --
   --option  --sub-bar
 zsh_expected: |
   > crazy-complete-test subcommand --option lastcommand --
