Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pending UI #2077

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/watch/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct WatchState<'a> {
show_hint: bool,
done_status: DoneStatus,
manual_run: bool,
pending: bool,
}

impl<'a> WatchState<'a> {
Expand All @@ -40,6 +41,7 @@ impl<'a> WatchState<'a> {
show_hint: false,
done_status: DoneStatus::Pending,
manual_run,
pending: false,
}
}

Expand All @@ -51,6 +53,10 @@ impl<'a> WatchState<'a> {
pub fn run_current_exercise(&mut self) -> Result<()> {
self.show_hint = false;

self.pending = true;
self.render()?;
self.pending = false; // remove pending UI on next render

let success = self
.app_state
.current_exercise()
Expand Down Expand Up @@ -164,6 +170,13 @@ When you are done experimenting, enter `n` to move on to the next exercise 🦀"

self.show_prompt()?;

// TODO remove the whole pending logic once this is fixed:
// https://github.com/rust-lang/rustlings/issues/2071
if self.pending {
self.writer
.write_all(b"\n\nChecking the exercises...\n\nThank you for your patience...\n")?;
}

Ok(())
}

Expand Down