Skip to content

Conversation

@srietkerk
Copy link
Contributor

@srietkerk srietkerk commented Dec 9, 2025

Fixes microsoft/pxt-arcade#3690

Code generated by copilot.

Limiting asset names to only ASCII characters makes searches for assets with non-Latin-based languages fail, thus not populating the icon that allows users to edit those assets. This is particularly relevant to tilemaps because once the tilemap is edited, we give it a localized default name, and that name is used to reference the asset itself. This doesn't happen by default to our other field editors because we have objects that we use for the asset itself that don't necessarily rely on the localized asset name (the image or the song, for example).

Upload target: https://arcade.makecode.com/app/2aadb1f4086b9d0e98310aedae8176c11f6d1535-09e8053e58#

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue where Unicode characters in tilemap asset names prevented the tilemap icon from appearing in text editors. The fix updates regex patterns across multiple Monaco field editors (tilemap, sprite, music, animation) to support Unicode asset names by replacing restrictive ASCII-only character classes with more permissive patterns.

Key Changes

  • Updated regex matchers from ASCII-only patterns ([a-zA-Z0-9_]) to Unicode-supporting patterns ([^delimiter]*)
  • Applied changes consistently across sprite, music, and animation field editors
  • Updated tilemap field editor with similar intent but with a pattern issue (see comments)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pxteditor/monaco-fields/field_tilemap.ts Updated regex matcher to support Unicode in tilemap names, but uses combined pattern that may cause issues
pxteditor/monaco-fields/field_sprite.ts Correctly updated assets.image patterns for both TypeScript and Python to support Unicode
pxteditor/monaco-fields/field_musiceditor.ts Correctly updated assets.song patterns for both TypeScript and Python to support Unicode
pxteditor/monaco-fields/field_animation.ts Correctly updated assets.animation patterns for both TypeScript and Python to support Unicode

// match both JS and python
searchString: "(?:tilemap(?:8|16|32)?\\s*(?:`|\\(\"\"\")(?:[ a-zA-Z0-9_]|\\n)*\\s*(?:`|\"\"\"\\)))|(?:tiles\\s*\\.\\s*createTilemap\\s*\\([^\\)]+\\))",
// match both JS and python, allowing Unicode characters in tilemap names
searchString: "(?:tilemap(?:8|16|32)?\\s*(?:`|\\(\"\"\")(?:[^`\"]|\\n)*\\s*(?:`|\"\"\"\\)))|(?:tiles\\s*\\.\\s*createTilemap\\s*\\([^\\)]+\\))",
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern [^"]` excludes both backticks and double-quotes, which creates issues for matching tilemap names:

  • In backtick syntax (tilemap`name`), names containing " won't match
  • In triple-quote syntax (tilemap("""name""")), names containing ` won't match

The pattern should be split into separate alternatives that each exclude only their respective delimiter:

searchString: "(?:tilemap(?:8|16|32)?\\s*`[^`]*`)|(?:tilemap(?:8|16|32)?\\s*\\(\\\"\\\"\\\"[^\"]*\\\"\\\"\\\"\\))|(?:tiles\\s*\\.\\s*createTilemap\\s*\\([^\\)]+\\))",

This matches the approach used in the parsing regex at line 42.

Suggested change
searchString: "(?:tilemap(?:8|16|32)?\\s*(?:`|\\(\"\"\")(?:[^`\"]|\\n)*\\s*(?:`|\"\"\"\\)))|(?:tiles\\s*\\.\\s*createTilemap\\s*\\([^\\)]+\\))",
searchString: "(?:tilemap(?:8|16|32)?\\s*`[^`]*`)|(?:tilemap(?:8|16|32)?\\s*\\(\"\"\"[^\"]*\"\"\"\\))|(?:tiles\\s*\\.\\s*createTilemap\\s*\\([^\\)]+\\))",

Copilot uses AI. Check for mistakes.
@srietkerk srietkerk enabled auto-merge (squash) December 17, 2025 23:26
@srietkerk srietkerk merged commit 2a1d317 into master Dec 17, 2025
20 checks passed
@srietkerk srietkerk deleted the srietkerk/asset-editor-icon-fix branch December 17, 2025 23:35
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.

The tile map icon will disappear in Chinese

3 participants