mirror of
https://github.com/latex-lsp/texlab.git
synced 2025-08-04 10:49:55 +00:00
Use rootDirectory setting to resolve output files
This commit is contained in:
parent
a675ddffe0
commit
54d0651c5c
3 changed files with 20 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2156,6 +2156,7 @@ name = "texlab-protocol"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dunce 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures-boxed 0.1.0",
|
||||
"jsonrpc 0.1.0",
|
||||
|
|
|
@ -8,6 +8,7 @@ edition = "2018"
|
|||
|
||||
[dependencies]
|
||||
bytes = "0.5"
|
||||
dunce = "1.0"
|
||||
futures = "0.3"
|
||||
futures-boxed = { path = "../futures_boxed" }
|
||||
jsonrpc = { path = "../jsonrpc" }
|
||||
|
|
|
@ -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())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue