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

@ -395,6 +395,19 @@ impl<T, E: std::fmt::Display> WithContextUntyped<T> for Result<T, E> {
}
}
impl<T> WithContextUntyped<T> for Option<T> {
fn context_ut(self, loc: &'static str) -> Result<T> {
self.ok_or_else(|| Error::new(loc, ErrKind::None, None))
}
fn with_context_ut<F>(self, loc: &'static str, f: F) -> Result<T>
where
F: FnOnce() -> Option<Box<[(&'static str, String)]>>,
{
self.ok_or_else(|| Error::new(loc, ErrKind::None, f()))
}
}
/// The error prelude.
pub mod prelude {