AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.
Rust agent-memoryai-agentsbm25claude-codeclicode-searchcursordatabaseelasticsearchfull-text-searchhybrid-searchjsonllocal-firstmcpmcp-servermodel-context-protocolragrustsearch-enginevector-search
fix(search): do not cite a Windows drive letter as the line (#1695)
xerj-org680a0a530235
diff --git a/engine/crates/xerj-autoindex/src/search.rs b/engine/crates/xerj-autoindex/src/search.rsindex d0eda325e..28e3a68e8 100644--- a/engine/crates/xerj-autoindex/src/search.rs+++ b/engine/crates/xerj-autoindex/src/search.rs@@ -377,7 +377,7 @@ pub(crate) fn hit_location(hit: &Value) -> String {.and_then(Value::as_u64).or_else(|| passage_line(hit));match line {- Some(n) => format!("{path}:{n}"),+ Some(n) => xerj_common::xccode::passage::cite_path_line(path, n),None => path.to_string(),}}@@ -1072,6 +1072,15 @@ mod tests {});assert_eq!(hit_location(&symbol_hit), "crates/fjall/src/batch.rs:108");+ let windows_hit = json!({+ "_source": { "ax_path": "C:/src/main.rs", "line": 12 }+ });+ assert_eq!(+ hit_location(&windows_hit),+ "C:/src/main.rs (line 12)",+ "a drive letter must not be parsed as the line"+ );+let synthetic_defs_hit = json!({"_source": {"ax_path": "crates/fjall/src/batch.rs"diff --git a/engine/crates/xerj-common/src/xccode/passage.rs b/engine/crates/xerj-common/src/xccode/passage.rsindex 8a99228ce..37355a992 100644--- a/engine/crates/xerj-common/src/xccode/passage.rs+++ b/engine/crates/xerj-common/src/xccode/passage.rs@@ -222,6 +222,17 @@ pub fn best_window(body: &str, query: &str, width: usize) -> (String, usize, usi(win, start2, total)}+/// `path:line` when `path` has no colon. A Windows drive (`C:/src/main.rs`)+/// or any other colon in the path makes the first colon the drive, not the+/// line, so the line is written beside the path instead.+pub fn cite_path_line(path: &str, line: u64) -> String {+ if path.contains(':') {+ format!("{path} (line {line})")+ } else {+ format!("{path}:{line}")+ }+}+/// `file:line`, or the best locator the record actually carries. NEVER an/// invented line number — a fabricated citation is worse than none, because/// it survives review by looking checkable.@@ -235,7 +246,7 @@ pub fn provenance(src: &Value) -> String {.find_map(|k| src.get(*k).and_then(Value::as_u64)).filter(|n| *n != 0);match line {- Some(n) => format!("{path}:{n}"),+ Some(n) => cite_path_line(path, n),None => path.to_string(),}}@@ -380,6 +391,12 @@ mod tests {"line 0 is absent, not a line");assert_eq!(provenance(&json!({})), "?");+ assert_eq!(+ provenance(&json!({ "ax_path": "C:/src/main.rs", "line": 12 })),+ "C:/src/main.rs (line 12)",+ "the drive colon is not the line number"+ );+ assert_eq!(cite_path_line("src/lib.rs", 4), "src/lib.rs:4");}#[test]