Fixes CLI blocking upon opening pdf viewer (#706)

Fixes issue typst/typst#704 by making opening a pdf viewer non-blocking.
This does remove error reporting when the pdf viewer fails to be
opened. This error reporting is difficult to regain since the error
happens on a different thread.
This commit is contained in:
Timme Bethe 2023-04-11 14:06:38 +02:00 committed by GitHub
parent 6f625fc73c
commit ef50f1b011
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -348,13 +348,9 @@ fn print_diagnostics(
/// - The given viewer provided by `open` if it is `Some`.
fn open_file(open: Option<&str>, path: &Path) -> StrResult<()> {
if let Some(app) = open {
open::with(path, app).map_err(|err| {
format!("failed to open `{}` with `{}`, reason: {}", path.display(), app, err)
})?;
open::with_in_background(path, app);
} else {
open::that(path).map_err(|err| {
format!("failed to open `{}`, reason: {}", path.display(), err)
})?;
open::that_in_background(path);
}
Ok(())