Files
my-pkgs/pkgs/texlab/patches/subfile-diagnostics.patch
Luis Eduardo Bueso de Barrio 0e3a73a20e
All checks were successful
CI / Build Packages (default) (push) Successful in 52s
CI / Build Packages (example-a) (push) Successful in 49s
CI / Nix Flake Check (push) Successful in 1m58s
CI / Build Packages (example-b) (push) Successful in 48s
CI / Build Packages (pyzotero) (push) Successful in 53s
CI / Build Packages (pyzotero-cli) (push) Successful in 56s
texlab-patched
2026-03-06 15:17:45 +01:00

37 lines
1.5 KiB
Diff

diff --git a/crates/diagnostics/src/build_log.rs b/crates/diagnostics/src/build_log.rs
index 1234567..abcdefg 100644
--- a/crates/diagnostics/src/build_log.rs
+++ b/crates/diagnostics/src/build_log.rs
@@ -14,8 +14,13 @@ pub fn update(
let data = log_document.data.as_log()?;
- let parents = deps::parents(workspace, log_document);
- let root_document = parents.iter().next()?;
+ // Try to find the compiled .tex file from the log file name first.
+ // This handles subfile compilation where the subfile is the actual root.
+ let root_document = find_compiled_document(workspace, log_document)
+ .or_else(|| {
+ // Fallback to original behavior: find parent via dependency graph
+ deps::parents(workspace, log_document).into_iter().next()
+ })?;
let base_path = root_document
.path
@@ -57,3 +62,14 @@ fn find_range_of_hint(document: &Document, error: &BuildError) -> Option<TextRan
let hint_end = hint_start + hint.text_len();
Some(TextRange::new(hint_start, hint_end))
}
+
+/// Given a .log file, find the corresponding .tex file that was compiled.
+/// E.g., `/path/to/chapter.log` -> `/path/to/chapter.tex`
+fn find_compiled_document<'a>(
+ workspace: &'a Workspace,
+ log_document: &Document,
+) -> Option<&'a Document> {
+ let log_path = log_document.path.as_ref()?;
+ let tex_path = log_path.with_extension("tex");
+ let tex_uri = Url::from_file_path(&tex_path).ok()?;
+ workspace.lookup(&tex_uri)
+}