Skip to content

Commit

Permalink
Fix loading bibliographies from TeX distro
Browse files Browse the repository at this point in the history
See #923.
  • Loading branch information
pfoerster committed Sep 24, 2023
1 parent 2c9c262 commit b2a49d0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Allow passing additional arguments to `ChkTeX` using `texlab.chktex.additionalArgs` ([#927](https://github.com/latex-lsp/texlab/issues/927))

### Fixed

- Fix loading bibliographies from `kpathsea` search path ([#923](https://github.com/latex-lsp/texlab/issues/923))

## [5.9.2] - 2023-08-14

### Fixed
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

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

5 changes: 4 additions & 1 deletion crates/base-db/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ impl<'a> Graph<'a> {
let distro_files = file_names
.iter()
.filter_map(|name| file_name_db.get(name))
.filter(|path| home_dir.map_or(false, |dir| path.starts_with(dir)))
.filter(|path| {
home_dir.map_or(false, |dir| path.starts_with(dir))
|| Language::from_path(path) == Some(Language::Bib)
})
.flat_map(Url::from_file_path);

for target_uri in file_names
Expand Down
6 changes: 4 additions & 2 deletions crates/base-db/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ impl Workspace {
fn discover_parents(&mut self, checked_paths: &mut FxHashSet<PathBuf>) -> bool {
let dirs = self
.iter()
.filter(|document| document.language != Language::Bib)
.filter_map(|document| document.path.as_deref())
.flat_map(|path| path.ancestors().skip(1))
.filter(|path| self.contains(path))
Expand Down Expand Up @@ -296,11 +297,12 @@ impl Workspace {
let Some(lang) = Language::from_path(&file) else {
continue;
};

if !matches!(lang, Language::Tex | Language::Root | Language::Tectonic) {
continue;
}

if self.lookup_path(&file).is_none() {
if self.lookup_path(&file).is_none() && file.exists() {
changed |= self.load(&file, lang, Owner::Server).is_ok();
checked_paths.insert(file);
}
Expand All @@ -322,7 +324,7 @@ impl Workspace {
let mut changed = false;
for file in files {
let language = Language::from_path(&file).unwrap_or(Language::Tex);
if self.lookup_path(&file).is_none() {
if self.lookup_path(&file).is_none() && file.exists() {
changed |= self.load(&file, language, Owner::Server).is_ok();
checked_paths.insert(file);
}
Expand Down
1 change: 0 additions & 1 deletion crates/texlab/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ completion-data = { path = "../completion-data" }
crossbeam-channel = "0.5.8"
definition = { path = "../definition" }
diagnostics = { path = "../diagnostics" }
dirs = "5.0.1"
distro = { path = "../distro" }
encoding_rs = "0.8.33"
encoding_rs_io = "0.1.7"
Expand Down
9 changes: 1 addition & 8 deletions crates/texlab/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ pub mod diagnostics;
pub mod line_index_ext;
pub mod lsp_enums;

use std::path::PathBuf;

use lsp_types::Url;
use once_cell::sync::Lazy;

pub static HOME_DIR: Lazy<Option<PathBuf>> = Lazy::new(dirs::home_dir);

pub fn normalize_uri(uri: &mut Url) {
pub fn normalize_uri(uri: &mut lsp_types::Url) {
if let Some(mut segments) = uri.path_segments() {
if let Some(mut path) = segments.next().and_then(fix_drive_letter) {
for segment in segments {
Expand Down

0 comments on commit b2a49d0

Please sign in to comment.