feat: support one-to-many language mapping in emmet.includeLanguages - #331033
Open
Genius740Code wants to merge 2 commits into
Open
feat: support one-to-many language mapping in emmet.includeLanguages#331033Genius740Code wants to merge 2 commits into
Genius740Code wants to merge 2 commits into
Conversation
Adds support for mapping a single file extension to multiple Emmet languages
via array syntax in emmet.includeLanguages configuration. For example:
emmet.includeLanguages: { tt: [html, css, javascript] }
Changes:
- Update package.json schema to accept both string and array values
- Modify getMappingForIncludedLanguages() to handle array mappings
- Update completion provider registration to merge trigger characters from multiple languages
- Enhance completion provider logic to try multiple languages when using array mappings
- Update abbreviation actions to handle array mappings
- Add comprehensive test coverage for new functionality
- Maintain full backward compatibility with existing string-based configurations
Fixes microsoft#62910
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for one-to-many emmet.includeLanguages mappings (string or string[]) so Emmet can resolve multiple candidate modes (e.g., HTML + CSS) for a single language and merge completion trigger characters accordingly.
Changes:
- Extend
emmet.includeLanguagessetting schema and mapping utilities to acceptstring | string[]. - Update completion / abbreviation resolution logic to try multiple mapped languages in order and merge trigger characters.
- Add/extend tests covering array mappings, filtering invalid entries, and backward compatibility.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/emmet/src/util.ts | Broadens mapping + mode resolution types to support array mappings. |
| extensions/emmet/src/test/util.test.ts | New tests for getMappingForIncludedLanguages including array filtering behavior. |
| extensions/emmet/src/test/completion.test.ts | Adds completion-provider tests for array mappings (HTML/CSS), invalid entries, and empty arrays. |
| extensions/emmet/src/test/abbreviationAction.test.ts | Adds expansion/completion tests for array mapping behavior in script-tag contexts. |
| extensions/emmet/src/emmetCommon.ts | Updates provider registration logic to handle array mappings and merge trigger characters. |
| extensions/emmet/src/defaultCompletionProvider.ts | Tries multiple mapped languages when determining Emmet mode. |
| extensions/emmet/src/abbreviationActions.ts | Extends syntax resolution from args to support array mappings for language/parentMode. |
| extensions/emmet/package.json | Updates config schema to allow emmet.includeLanguages values to be string or string[]. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+13
to
+16
| test('Should return empty object when no config is set', () => { | ||
| const mapping = getMappingForIncludedLanguages(); | ||
| assert.ok(mapping); | ||
| assert.strictEqual(Object.keys(mapping).length, 0); |
Comment on lines
195
to
196
| clearCompletionProviderInfo(); | ||
|
|
Comment on lines
230
to
232
| if (languageMappingForCompletionProviders.has(language) && areMappingsEqual(languageMappingForCompletionProviders.get(language)!, mapping)) { | ||
| return; | ||
| } |
- Add proper config isolation in util.test.ts by explicitly setting includeLanguages to undefined and restoring original config in finally block - Remove dead areMappingsEqual function and its ineffective usage in refreshCompletionProviders since clearCompletionProviderInfo() clears the map before the equality check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for mapping a single file extension to multiple Emmet languages via array syntax in emmet.includeLanguages configuration. For example: emmet.includeLanguages: { tt: [html, css, javascript] }
Changes:
Fixes #62910