pub fn launch_via(
path: &Path,
candidates: &[String],
run: &mut dyn FnMut(&mut Command) -> Result<EditorRunOutcome>,
) -> Result<()>Expand description
Try each candidate in order and return once one runs to completion.
run is injected so every arm - including “no editor found” - is reachable
under test on every platform without spawning a real, blocking, interactive
editor. That matters most on Windows: Command::new("notepad") resolves
through the System32 search path that CreateProcess consults before
$PATH, so it cannot be made to fail short of tampering with a real system
directory, and letting it actually open would hang CI with no timeout.
run is &mut dyn FnMut rather than impl FnMut because several test call
sites pass distinct closure literals, and a generic parameter would give
each one its own coverage-mapping instantiation. cargo llvm-cov sometimes
reports a region as uncovered for one instantiation even when the union of
all of them covers every source position.