Skip to content

Commit

Permalink
Add pexpect test for commandline --showing-suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
mqudsi committed Jun 27, 2024
1 parent 975a7b9 commit e512820
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,8 @@ pub fn reader_showing_suggestion(parser: &Parser) -> bool {
}
if let Some(data) = current_data() {
let reader = Reader { parser, data };
// HACK: try to work around CI issues <JUST FOR TESTING>
std::thread::sleep(Duration::from_millis(100));
!reader.autosuggestion.is_empty()
} else {
false
Expand Down
22 changes: 22 additions & 0 deletions tests/pexpects/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@
)
expect_prompt()

# Test --showing-suggestion before we dirty the history
sendline("echo hello")
expect_prompt()
sendline("function debug; commandline --showing-suggestion; set -g cmd_status $status; end")
expect_prompt()
sendline("bind ctrl-p debug");
expect_prompt()
send("echo hell")
sleep(0.1) # wait for suggestion to appear under CI
send(control("p"))
sendline("")
expect_prompt("hell")
sendline("echo cmd_status: $cmd_status")
expect_prompt("cmd_status: 0")
send("echo goodb")
sleep(0.1) # wait for suggestion to appear under CI
send(control("p"))
sendline("")
expect_prompt("goodb")
sendline("echo cmd_status: $cmd_status")
expect_prompt("cmd_status: 1")

sendline("bind '~' 'handle_tilde'")
expect_prompt()

Expand Down

0 comments on commit e512820

Please sign in to comment.