fix: try getting font index again (#1213, #1645) (#1790)
Some checks are pending
tinymist::ci / E2E Tests (win32-x64 on windows-2019) (push) Blocked by required conditions
tinymist::ci / E2E Tests (linux-x64 on ubuntu-22.04) (push) Blocked by required conditions
tinymist::ci / E2E Tests (linux-x64 on ubuntu-latest) (push) Blocked by required conditions
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 / E2E Tests (darwin-arm64 on macos-latest) (push) Blocked by required conditions
tinymist::ci / E2E Tests (win32-x64 on windows-latest) (push) Blocked by required conditions
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / build-binary (push) Blocked by required conditions
tinymist::ci / build-vsc-assets (push) Blocked by required conditions
tinymist::ci / build-vscode (push) Blocked by required conditions
tinymist::ci / build-vscode-others (push) Blocked by required conditions
tinymist::ci / publish-vscode (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run

This commit is contained in:
Myriad-Dreamin 2025-06-04 15:06:19 +08:00 committed by GitHub
parent 08a104cd9c
commit 646dd81a35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -178,9 +178,9 @@ impl FontResolverImpl {
None
}
/// Describes the source of a font by id.
pub fn describe_font_by_id(&self, id: usize) -> Option<Arc<DataSource>> {
self.slots[id].description.clone()
/// Describes the source of a font by index.
pub fn describe_font_by_id(&self, index: usize) -> Option<Arc<DataSource>> {
self.slot(index)?.description.clone()
}
pub fn with_font_paths(mut self, font_paths: Vec<PathBuf>) -> Self {
@ -198,8 +198,8 @@ impl FontResolver for FontResolverImpl {
self.slots.get(idx)
}
fn font(&self, idx: usize) -> Option<Font> {
self.slots[idx].get_or_init()
fn font(&self, index: usize) -> Option<Font> {
self.slot(index)?.get_or_init()
}
fn get_by_info(&self, info: &FontInfo) -> Option<Font> {