summaryrefslogtreecommitdiff
path: root/src/watch.rs
diff options
context:
space:
mode:
authorsotanengel <84895123+sotanengel@users.noreply.github.com>2024-09-29 11:09:34 +0900
committerGitHub <noreply@github.com>2024-09-29 11:09:34 +0900
commitf0a2cdeb188c0ade20990e01e3230ce946baec2f (patch)
treeeeaf3ebe89c6fc4610b7023c08411bfe6fd93745 /src/watch.rs
parente3ec0abca464f337515f79d256c26b208d08b4a5 (diff)
parent0c79f2ea3e1fd2db54ebe8fba8ed17369a15b365 (diff)
Merge branch 'rust-lang:main' into add/link-to-THIRD_PARTY-repository-for-Japanese-translations
Diffstat (limited to 'src/watch.rs')
-rw-r--r--src/watch.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/watch.rs b/src/watch.rs
index fd89b29..35533b0 100644
--- a/src/watch.rs
+++ b/src/watch.rs
@@ -69,11 +69,11 @@ fn run_watch(
// Prevent dropping the guard until the end of the function.
// Otherwise, the file watcher exits.
let _watcher_guard = if let Some(exercise_names) = notify_exercise_names {
+ let notify_event_handler =
+ NotifyEventHandler::build(watch_event_sender.clone(), exercise_names)?;
+
let mut watcher = RecommendedWatcher::new(
- NotifyEventHandler {
- sender: watch_event_sender.clone(),
- exercise_names,
- },
+ notify_event_handler,
Config::default().with_poll_interval(Duration::from_secs(1)),
)
.inspect_err(|_| eprintln!("{NOTIFY_ERR}"))?;
@@ -100,13 +100,14 @@ fn run_watch(
ExercisesProgress::NewPending => watch_state.run_current_exercise(&mut stdout)?,
ExercisesProgress::CurrentPending => (),
},
+ WatchEvent::Input(InputEvent::Run) => watch_state.run_current_exercise(&mut stdout)?,
WatchEvent::Input(InputEvent::Hint) => watch_state.show_hint(&mut stdout)?,
WatchEvent::Input(InputEvent::List) => return Ok(WatchExit::List),
+ WatchEvent::Input(InputEvent::Reset) => watch_state.reset_exercise(&mut stdout)?,
WatchEvent::Input(InputEvent::Quit) => {
stdout.write_all(QUIT_MSG)?;
break;
}
- WatchEvent::Input(InputEvent::Run) => watch_state.run_current_exercise(&mut stdout)?,
WatchEvent::FileChange { exercise_ind } => {
watch_state.handle_file_change(exercise_ind, &mut stdout)?;
}