Conversation
…s/language-tools) volar-service-typescript only read the deprecated per-language `typescript.format.*` / `javascript.format.*` settings when formatting embedded script blocks, ignoring the unified `js/ts.format.*` settings. VS Code's built-in TS extension reads `js/ts.format.*` first and only falls back to the language-specific sections when the unified value is not configured. Mirror that behavior so Vue script blocks format consistently with regular TS/JS files.
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.
Problem
Volar's TypeScript formatting service only reads the deprecated per-language format settings (
typescript.format.*/javascript.format.*) when formatting embedded script blocks. The unifiedjs/ts.format.*settings are ignored, so a Vue<script setup lang="ts">block formats differently from a regular.tsfile when only the unified settings are configured.Closes vuejs/language-tools#6150
What VS Code does
VS Code's built-in TypeScript extension reads the unified
js/ts.format.*settings first and only falls back to the language-specific sections (typescript.format.*/javascript.format.*) when the unified value is not configured — seereadUnifiedConfig.Change
getFormatCodeSettingsnow also readsjs/ts.formatand gives those values precedence over the language-specific sections, while still falling back to the deprecated settings.One caveat worth noting for reviewers:
LanguageServiceEnvironment.getConfigurationonly returns resolved values (including registered defaults), with noinspect()-style "was this explicitly set" signal. So we approximate the unified-wins fallback by preferring a unified value only when it differs from its registered default. This behaves identically to VS Code in practice; the only theoretical divergence is explicitly setting a unified key to its exact default while also setting the deprecated counterpart to a different value.Test plan
Added unit tests covering:
js/ts.format.*settings are honoredtypescript.format.*/javascript.format.*