Skip to content

Port upstream Muya cpp alias idempotence#58

Open
Renakoni wants to merge 2 commits into
mainfrom
sync/upstream-4816-cpp-alias-idempotent
Open

Port upstream Muya cpp alias idempotence#58
Renakoni wants to merge 2 commits into
mainfrom
sync/upstream-4816-cpp-alias-idempotent

Conversation

@Renakoni

@Renakoni Renakoni commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Ports upstream marktext/marktext PR #4816 into the Android Muya copy.

Upstream source: marktext/marktext#4816

This is a follow-up to upstream #4794, so this Android PR is intentionally stacked on Android PR #54 (sync/upstream-4794-cpp-alias). It keeps the one-upstream-PR-to-one-Android-PR mapping while avoiding a misleading PR against main before the alias registration exists there.

Changes

  • Makes c++ / h++ alias registration idempotent by adding each alias only when it is absent.
  • Prevents duplicated aliases when the Prism module is evaluated multiple times in tests or HMR.
  • Extends the alias regression test to reset/re-import the module and assert each alias appears exactly once.

Verification

  • pnpm test -- src/utils/prism/__tests__/languageAlias.spec.ts from third_party/muya passed: 5 tests.
  • pnpm exec eslint src/utils/prism/index.ts src/utils/prism/__tests__/languageAlias.spec.ts --no-ignore --max-warnings 0 from third_party/muya passed.
  • pnpm typecheck from repo root passed.

Audit Decision

This upstream PR is Android-relevant because it hardens the Muya Prism initialization path used by the Android WebView editor. It depends on the alias registration ported in Android PR #54, so this PR targets that branch rather than main.

Base automatically changed from sync/upstream-4794-cpp-alias to main July 9, 2026 00:02
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