Skip to content

Commit

Permalink
Use rootDirectory setting to resolve output files
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed Feb 26, 2020
1 parent a675ddf commit 54d0651
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/texlab_protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2018"

[dependencies]
bytes = "0.5"
dunce = "1.0"
futures = "0.3"
futures-boxed = { path = "../futures_boxed" }
jsonrpc = { path = "../jsonrpc" }
Expand Down
23 changes: 18 additions & 5 deletions crates/texlab_protocol/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,25 @@ impl Options {
pub fn resolve_output_file(&self, tex_path: &Path, extension: &str) -> Option<PathBuf> {
let stem = tex_path.file_stem()?.to_str()?;
let name = format!("{}.{}", stem, extension);
let output_directory = self
.latex

self.latex
.as_ref()
.and_then(|latex| latex.build.as_ref())
.and_then(|build| build.output_directory.clone())
.unwrap_or_else(|| PathBuf::from("."));
Some(tex_path.parent()?.join(output_directory).join(name))
.and_then(|build| build.output_directory.as_ref())
.map(|path| path.join(&name))
.and_then(|path| dunce::canonicalize(path).ok())
.or_else(|| {
self.latex
.as_ref()
.and_then(|latex| latex.root_directory.as_ref())
.map(|path| path.join(&name))
.and_then(|path| dunce::canonicalize(path).ok())
})
.or_else(|| {
tex_path
.parent()
.map(|path| path.join(&name))
.and_then(|path| dunce::canonicalize(path).ok())
})
}
}

0 comments on commit 54d0651

Please sign in to comment.