Revert "Turn on rootDirectory setting by default"

This reverts commit 070d3829e6.
This commit is contained in:
Patrick Förster 2020-02-27 17:22:32 +01:00
parent 070d3829e6
commit 190142cee9
4 changed files with 17 additions and 30 deletions

View file

@ -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('\\', "/"));

View file

@ -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)]
@ -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)]
@ -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())
})

View file

@ -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,
@ -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| {

View file

@ -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())