Skip to content

Commit

Permalink
Use root directory when completing includes
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed Feb 27, 2020
1 parent 0d88c3a commit 630f72c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions crates/texlab_completion/src/latex/include.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,22 @@ fn current_directory(
request: &FeatureRequest<CompletionParams>,
command: &LatexCommand,
) -> PathBuf {
let mut path = request.document().uri.to_file_path().unwrap();
let mut path = request
.options
.latex
.as_ref()
.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('\\', "/"));

path.pop();
if let Some(include) = command.extract_word(0) {
path.push(include.text());
if !include.text().ends_with('/') {
Expand Down

0 comments on commit 630f72c

Please sign in to comment.