Skip to content

Commit

Permalink
Revert "Turn on rootDirectory setting by default"
Browse files Browse the repository at this point in the history
This reverts commit 070d382.
  • Loading branch information
pfoerster committed Feb 27, 2020
1 parent 070d382 commit 190142c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 30 deletions.
15 changes: 9 additions & 6 deletions crates/texlab_completion/src/latex/include.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ fn current_directory(
.options
.latex
.as_ref()
.and_then(|latex| latex.root_directory())
.unwrap_or_else(|| {
let mut path = request.document().uri.to_file_path().unwrap();
path.pop();
path
});
.and_then(|latex| latex.root_directory.as_ref())
.map_or_else(
|| {
let mut path = request.document().uri.to_file_path().unwrap();
path.pop();
path
},
Clone::clone,
);

path = PathBuf::from(path.to_string_lossy().into_owned().replace('\\', "/"));

Expand Down
23 changes: 3 additions & 20 deletions crates/texlab_protocol/src/options.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::{Deserialize, Deserializer, Serialize};
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};

#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)]
Expand Down Expand Up @@ -68,24 +68,7 @@ pub struct LatexOptions {
pub forward_search: Option<LatexForwardSearchOptions>,
pub lint: Option<LatexLintOptions>,
pub build: Option<LatexBuildOptions>,
#[serde(default, deserialize_with = "deserialize_some")]
pub root_directory: Option<Option<PathBuf>>,
}

fn deserialize_some<'de, T, D>(deserializer: D) -> Result<Option<T>, D::Error>
where
T: Deserialize<'de>,
D: Deserializer<'de>,
{
Deserialize::deserialize(deserializer).map(Some)
}

impl LatexOptions {
pub fn root_directory(&self) -> Option<PathBuf> {
self.root_directory
.clone()
.unwrap_or_else(|| Some(PathBuf::from(".")))
}
pub root_directory: Option<PathBuf>,
}

#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)]
Expand Down Expand Up @@ -115,7 +98,7 @@ impl Options {
.or_else(|| {
self.latex
.as_ref()
.and_then(|latex| latex.root_directory())
.and_then(|latex| latex.root_directory.as_ref())
.map(|path| path.join(&name))
.and_then(|path| dunce::canonicalize(path).ok())
})
Expand Down
4 changes: 2 additions & 2 deletions crates/texlab_syntax/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::path::PathBuf;
use texlab_distro::{Language, Resolver};
use texlab_protocol::{Options, Uri};

#[derive(Debug, PartialEq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct SyntaxTreeInput<'a> {
pub options: &'a Options,
pub resolver: &'a Resolver,
Expand All @@ -28,7 +28,7 @@ impl<'a> SyntaxTreeInput<'a> {
self.options
.latex
.as_ref()
.and_then(|opts| opts.root_directory())
.and_then(|opts| opts.root_directory.as_ref())
.and_then(|path| dunce::canonicalize(path).ok())
.or_else(|| {
self.uri.to_file_path().ok().map(|mut path| {
Expand Down
5 changes: 3 additions & 2 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ where
.map(Clone::clone)
.unwrap_or_default();

let root_directory = self.options.root_directory();
let build_dir = root_directory
let build_dir = self
.options
.root_directory
.as_ref()
.map(AsRef::as_ref)
.or_else(|| path.parent())
Expand Down

0 comments on commit 190142c

Please sign in to comment.