fix: the path to join is shadowed by a local variable (#1322) (#1335)

* fix: the path to join is shadowed by a local variable

* fix: redact target uri
This commit is contained in:
Myriad-Dreamin 2025-02-20 00:50:10 +08:00 committed by GitHub
parent cb51d67e7d
commit 9904189910
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 49 additions and 2 deletions

View file

@ -37,3 +37,19 @@ impl SemanticRequest for DocumentLinkRequest {
Some(links.collect())
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::tests::*;
#[test]
fn test() {
snapshot_testing("document_link", &|ctx, path| {
let request = DocumentLinkRequest { path: path.clone() };
let result = request.request(ctx);
assert_snapshot!(JsonRepr::new_redacted(result, &REDACT_LOC));
});
}
}

View file

@ -0,0 +1,4 @@
/// path: base.json
{}
-----
#json(/* position after */ "base.json");

View file

@ -0,0 +1,3 @@
/// path: base.typ
-----
#read(/* position after */ "base.typ");

View file

@ -0,0 +1,11 @@
---
source: crates/tinymist-query/src/document_link.rs
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/document_link/json_path.typ
---
[
{
"range": "0:28:0:37",
"target": "base.json"
}
]

View file

@ -0,0 +1,11 @@
---
source: crates/tinymist-query/src/document_link.rs
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/document_link/read_path.typ
---
[
{
"range": "0:28:0:36",
"target": "base.typ"
}
]

View file

@ -344,6 +344,7 @@ pub static REDACT_LOC: Lazy<RedactFields> = Lazy::new(|| {
"targetRange",
"targetSelectionRange",
"originSelectionRange",
"target",
"targetUri",
])
});
@ -416,7 +417,7 @@ impl Redact for RedactFields {
),
);
}
"uri" | "oldUri" | "newUri" | "targetUri" => {
"uri" | "target" | "oldUri" | "newUri" | "targetUri" => {
map.insert(key.to_owned(), file_name(t.as_str().unwrap()).into());
}
"range"