Skip to content

fix(rune-kit): require path separator boundary in kit_metrics descendant lookups - #2220

Merged
Hona merged 1 commit into
devfrom
fix/noticed-kit-metrics
Nov 25, 2026
Merged

Hona merged 1 commit into
devfrom
fix/noticed-kit-metrics

Conversation

@Hona

@Hona Hona commented Nov 25, 2026

Copy link
Copy Markdown
Member

Cause

In crates/rune-kit/tests/integration/kit_metrics.rs (added in #2172, d1534ad13), both failing assertions were bugs in the test's descendant-lookup helpers (under and input), not in the Kit::metrics production code:

  • under("field", "input") checked e.path.starts_with(path) where path = "#0/field". Because #0/field-default precedes #0/field in els, "#0/field-default/value/input".starts_with("#0/field") matched field-default's input (x = 8.0) instead of field's input (x = 11.0).
  • input("area") checked e.path.starts_with("#0/area"), which matched #0/area-default/input (x = 8.0, y = 8.0) instead of #0/area/input (x = 12.0, y = 92.0), producing (8.0 - 0.0, 8.0 - 80.0) = (8.0, -72.0) instead of (12.0, 12.0).

Default check with Kit::metrics unset: every default in crates/rune-kit/src/tokens/metrics.rs matches the pre-#2172 hardcoded values identically, all 51 accessibility golden tests pass unchanged, and kit-gallery::every_story_builds passes.

Fix

Require a / segment boundary (e.path.strip_prefix(path.as_str()).is_some_and(|rest| rest.starts_with('/'))) in under and input in crates/rune-kit/tests/integration/kit_metrics.rs.

Verification

  • Windows x86_64 (at 4f8a7d140, before unrelated #2206 broke TextSpec size on dev): entire rune-kit test suite with --features markdown,mermaid passed (237 lib + 51 a11y + 308 integration + 105 markdown + 16 mermaid + 170 doctests = 887 passed; 0 failed), cargo test -p kit-gallery every_story_builds (1 passed), cargo clippy -p rune-kit --features markdown,mermaid --lib --bins --tests (exit 0), scripts/file-size.sh (0 errors).
  • macOS arm64 & Linux aarch64: blocked on current dev by unrelated 38f8dc54c (feat(selection): El::selection_enabled(bool), a subtree or window switch for selectable text #2206) failing const _: () = assert!(std::mem::size_of::<TextSpec>() == 224) in crates/rune/src/el/text_spec.rs:196; this PR changes only pure platform-independent test code in kit_metrics.rs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant