feat: add PathAt code context query (#2232)
Some checks are pending
tinymist::auto_tag / auto-tag (push) Waiting to run
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / announce (push) Blocked by required conditions
tinymist::ci / build (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run

This is used for custom paste scripts

- by pattern: e.g. `$root`
- by code: e.g. `{ root }`
- on conflict callback: e.g. `{ (dir: root, on-conflict: root + "/" +
random() + ".png") }`
This commit is contained in:
Myriad-Dreamin 2025-11-11 02:43:02 +08:00 committed by GitHub
parent c63162959d
commit c206933bf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 645 additions and 13 deletions

View file

@ -177,6 +177,7 @@ impl PathPattern {
let w = root.to_string_lossy();
let f = file_name.to_string_lossy();
let f = f.as_ref().strip_suffix(".typ").unwrap_or(f.as_ref());
// replace all $root
let mut path = self.0.replace("$root", &w);
@ -184,7 +185,7 @@ impl PathPattern {
let d = dir.to_string_lossy();
path = path.replace("$dir", &d);
}
path = path.replace("$name", &f);
path = path.replace("$name", f);
Some(Path::new(path.as_str()).clean().into())
}