diff --git a/extensions/typescript-language-features/package.json b/extensions/typescript-language-features/package.json index baf20de579d..66a1c65819d 100644 --- a/extensions/typescript-language-features/package.json +++ b/extensions/typescript-language-features/package.json @@ -442,6 +442,26 @@ "markdownDeprecationMessage": "%configuration.suggestionActions.enabled.unifiedDeprecationMessage%", "scope": "resource" }, + "js/ts.updateImportsOnFileMove.enabled": { + "type": "string", + "enum": [ + "prompt", + "always", + "never" + ], + "markdownEnumDescriptions": [ + "%typescript.updateImportsOnFileMove.enabled.prompt%", + "%typescript.updateImportsOnFileMove.enabled.always%", + "%typescript.updateImportsOnFileMove.enabled.never%" + ], + "default": "prompt", + "description": "%typescript.updateImportsOnFileMove.enabled%", + "scope": "resource", + "tags": [ + "JavaScript", + "TypeScript" + ] + }, "typescript.updateImportsOnFileMove.enabled": { "type": "string", "enum": [ @@ -456,6 +476,7 @@ ], "default": "prompt", "description": "%typescript.updateImportsOnFileMove.enabled%", + "markdownDeprecationMessage": "%configuration.updateImportsOnFileMove.enabled.unifiedDeprecationMessage%", "scope": "resource" }, "javascript.updateImportsOnFileMove.enabled": { @@ -472,20 +493,50 @@ ], "default": "prompt", "description": "%typescript.updateImportsOnFileMove.enabled%", + "markdownDeprecationMessage": "%configuration.updateImportsOnFileMove.enabled.unifiedDeprecationMessage%", "scope": "resource" }, + "js/ts.autoClosingTags.enabled": { + "type": "boolean", + "default": true, + "description": "%typescript.autoClosingTags%", + "scope": "language-overridable", + "tags": [ + "JavaScript", + "TypeScript" + ] + }, "typescript.autoClosingTags": { "type": "boolean", "default": true, "description": "%typescript.autoClosingTags%", + "markdownDeprecationMessage": "%configuration.autoClosingTags.enabled.unifiedDeprecationMessage%", "scope": "language-overridable" }, "javascript.autoClosingTags": { "type": "boolean", "default": true, "description": "%typescript.autoClosingTags%", + "markdownDeprecationMessage": "%configuration.autoClosingTags.enabled.unifiedDeprecationMessage%", "scope": "language-overridable" }, + "js/ts.workspaceSymbols.scope": { + "type": "string", + "enum": [ + "allOpenProjects", + "currentProject" + ], + "enumDescriptions": [ + "%typescript.workspaceSymbols.scope.allOpenProjects%", + "%typescript.workspaceSymbols.scope.currentProject%" + ], + "default": "allOpenProjects", + "markdownDescription": "%typescript.workspaceSymbols.scope%", + "scope": "window", + "tags": [ + "TypeScript" + ] + }, "typescript.workspaceSymbols.scope": { "type": "string", "enum": [ @@ -498,37 +549,72 @@ ], "default": "allOpenProjects", "markdownDescription": "%typescript.workspaceSymbols.scope%", + "markdownDeprecationMessage": "%configuration.workspaceSymbols.scope.unifiedDeprecationMessage%", "scope": "window" }, + "js/ts.preferGoToSourceDefinition": { + "type": "boolean", + "default": false, + "description": "%configuration.preferGoToSourceDefinition%", + "scope": "window", + "tags": [ + "JavaScript", + "TypeScript" + ] + }, "typescript.preferGoToSourceDefinition": { "type": "boolean", "default": false, "description": "%configuration.preferGoToSourceDefinition%", + "markdownDeprecationMessage": "%configuration.preferGoToSourceDefinition.unifiedDeprecationMessage%", "scope": "window" }, "javascript.preferGoToSourceDefinition": { "type": "boolean", "default": false, "description": "%configuration.preferGoToSourceDefinition%", + "markdownDeprecationMessage": "%configuration.preferGoToSourceDefinition.unifiedDeprecationMessage%", "scope": "window" }, + "js/ts.workspaceSymbols.excludeLibrarySymbols": { + "type": "boolean", + "default": true, + "markdownDescription": "%typescript.workspaceSymbols.excludeLibrarySymbols%", + "scope": "window", + "tags": [ + "TypeScript" + ] + }, "typescript.workspaceSymbols.excludeLibrarySymbols": { "type": "boolean", "default": true, "markdownDescription": "%typescript.workspaceSymbols.excludeLibrarySymbols%", + "markdownDeprecationMessage": "%configuration.workspaceSymbols.excludeLibrarySymbols.unifiedDeprecationMessage%", "scope": "window" }, + "js/ts.updateImportsOnPaste.enabled": { + "scope": "window", + "type": "boolean", + "default": true, + "markdownDescription": "%configuration.updateImportsOnPaste%", + "tags": [ + "JavaScript", + "TypeScript" + ] + }, "javascript.updateImportsOnPaste.enabled": { "scope": "window", "type": "boolean", "default": true, - "markdownDescription": "%configuration.updateImportsOnPaste%" + "markdownDescription": "%configuration.updateImportsOnPaste%", + "markdownDeprecationMessage": "%configuration.updateImportsOnPaste.enabled.unifiedDeprecationMessage%" }, "typescript.updateImportsOnPaste.enabled": { "scope": "window", "type": "boolean", "default": true, - "markdownDescription": "%configuration.updateImportsOnPaste%" + "markdownDescription": "%configuration.updateImportsOnPaste%", + "markdownDeprecationMessage": "%configuration.updateImportsOnPaste.enabled.unifiedDeprecationMessage%" }, "js/ts.hover.maximumLength": { "type": "number", diff --git a/extensions/typescript-language-features/package.nls.json b/extensions/typescript-language-features/package.nls.json index cc9fc7e38cc..799c5fedf2f 100644 --- a/extensions/typescript-language-features/package.nls.json +++ b/extensions/typescript-language-features/package.nls.json @@ -121,6 +121,7 @@ "configuration.suggest.autoImports": "Enable/disable auto import suggestions.", "configuration.suggest.autoImports.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.suggest.autoImports#` instead.", "configuration.preferGoToSourceDefinition": "Makes `Go to Definition` avoid type declaration files when possible by triggering `Go to Source Definition` instead. This allows `Go to Source Definition` to be triggered with the mouse gesture.", + "configuration.preferGoToSourceDefinition.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.preferGoToSourceDefinition#` instead.", "inlayHints.parameterNames.none": "Disable parameter name hints.", "inlayHints.parameterNames.literals": "Enable parameter name hints only for literal arguments.", "inlayHints.parameterNames.all": "Enable parameter name hints for literal and non-literal arguments.", @@ -215,11 +216,14 @@ "typescript.preferences.autoImportSpecifierExcludeRegexes": "Specify regular expressions to exclude auto imports with matching import specifiers. Examples:\n\n- `^node:`\n- `lib/internal` (slashes don't need to be escaped...)\n- `/lib\\/internal/i` (...unless including surrounding slashes for `i` or `u` flags)\n- `^lodash$` (only allow subpath imports from lodash)", "typescript.preferences.preferTypeOnlyAutoImports": "Include the `type` keyword in auto-imports whenever possible. Requires using TypeScript 5.3+ in the workspace.", "typescript.workspaceSymbols.excludeLibrarySymbols": "Exclude symbols that come from library files in `Go to Symbol in Workspace` results. Requires using TypeScript 5.3+ in the workspace.", + "configuration.workspaceSymbols.excludeLibrarySymbols.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.workspaceSymbols.excludeLibrarySymbols#` instead.", "typescript.updateImportsOnFileMove.enabled": "Enable/disable automatic updating of import paths when you rename or move a file in VS Code.", "typescript.updateImportsOnFileMove.enabled.prompt": "Prompt on each rename.", "typescript.updateImportsOnFileMove.enabled.always": "Always update paths automatically.", "typescript.updateImportsOnFileMove.enabled.never": "Never rename paths and don't prompt.", + "configuration.updateImportsOnFileMove.enabled.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.updateImportsOnFileMove.enabled#` instead.", "typescript.autoClosingTags": "Enable/disable automatic closing of JSX tags.", + "configuration.autoClosingTags.enabled.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.autoClosingTags.enabled#` instead.", "typescript.suggest.enabled": "Enable/disable autocomplete suggestions.", "configuration.suggest.enabled.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.suggest.enabled#` instead.", "configuration.suggest.completeJSDocs": "Enable/disable suggestion to complete JSDoc comments.", @@ -270,6 +274,7 @@ "typescript.workspaceSymbols.scope": "Controls which files are searched by [Go to Symbol in Workspace](https://code.visualstudio.com/docs/editor/editingevolved#_open-symbol-by-name).", "typescript.workspaceSymbols.scope.allOpenProjects": "Search all open JavaScript or TypeScript projects for symbols.", "typescript.workspaceSymbols.scope.currentProject": "Only search for symbols in the current JavaScript or TypeScript project.", + "configuration.workspaceSymbols.scope.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.workspaceSymbols.scope#` instead.", "typescript.sortImports": "Sort Imports", "typescript.removeUnusedImports": "Remove Unused Imports", "typescript.findAllFileReferences": "Find File References", @@ -283,6 +288,7 @@ "configuration.tsserver.web.typeAcquisition.enabled": "Enable/disable package acquisition on the web. This enables IntelliSense for imported packages. Requires `#typescript.tsserver.web.projectWideIntellisense.enabled#`. Currently not supported for Safari.", "configuration.tsserver.nodePath": "Run TS Server on a custom Node installation. This can be a path to a Node executable, or 'node' if you want VS Code to detect a Node installation.", "configuration.updateImportsOnPaste": "Automatically update imports when pasting code. Requires TypeScript 5.6+.", + "configuration.updateImportsOnPaste.enabled.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.updateImportsOnPaste.enabled#` instead.", "configuration.hover.maximumLength": "The maximum number of characters in a hover. If the hover is longer than this, it will be truncated. Requires TypeScript 5.9+.", "walkthroughs.nodejsWelcome.title": "Get started with JavaScript and Node.js", "walkthroughs.nodejsWelcome.description": "Make the most of Visual Studio Code's first-class JavaScript experience.", diff --git a/extensions/typescript-language-features/src/configuration/configuration.ts b/extensions/typescript-language-features/src/configuration/configuration.ts index 211beb52f40..22601ead8ea 100644 --- a/extensions/typescript-language-features/src/configuration/configuration.ts +++ b/extensions/typescript-language-features/src/configuration/configuration.ts @@ -291,8 +291,8 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu return configuration.get('typescript.tsserver.enableTracing', false); } - private readWorkspaceSymbolsExcludeLibrarySymbols(configuration: vscode.WorkspaceConfiguration): boolean { - return configuration.get('typescript.workspaceSymbols.excludeLibrarySymbols', true); + private readWorkspaceSymbolsExcludeLibrarySymbols(_configuration: vscode.WorkspaceConfiguration): boolean { + return readUnifiedConfig('workspaceSymbols.excludeLibrarySymbols', true, { scope: null, fallbackSection: 'typescript' }); } private readWebProjectWideIntellisenseEnable(configuration: vscode.WorkspaceConfiguration): boolean { diff --git a/extensions/typescript-language-features/src/languageFeatures/copyPaste.ts b/extensions/typescript-language-features/src/languageFeatures/copyPaste.ts index 98b14148d95..1cd85290466 100644 --- a/extensions/typescript-language-features/src/languageFeatures/copyPaste.ts +++ b/extensions/typescript-language-features/src/languageFeatures/copyPaste.ts @@ -11,8 +11,9 @@ import protocol from '../tsServer/protocol/protocol'; import * as typeConverters from '../typeConverters'; import { ClientCapability, ITypeScriptServiceClient, ServerResponse } from '../typescriptService'; import { raceTimeout } from '../utils/async'; +import { readUnifiedConfig } from '../utils/configuration'; import FileConfigurationManager from './fileConfigurationManager'; -import { conditionalRegistration, requireGlobalConfiguration, requireMinVersion, requireSomeCapability } from './util/dependentRegistration'; +import { conditionalRegistration, requireGlobalUnifiedConfig, requireMinVersion, requireSomeCapability } from './util/dependentRegistration'; class CopyMetadata { @@ -75,7 +76,7 @@ class TsPendingPasteEdit extends TsPasteEdit { } } -const enabledSettingId = 'updateImportsOnPaste.enabled'; +const enabledSettingId = 'updateImportsOnPaste.enabled' as const; class DocumentPasteProvider implements vscode.DocumentPasteEditProvider { @@ -239,8 +240,7 @@ class DocumentPasteProvider implements vscode.DocumentPasteEditProvider(enabledSettingId, true, { scope: document, fallbackSection: this._modeId }); } } @@ -248,7 +248,7 @@ export function register(selector: DocumentSelector, language: LanguageDescripti return conditionalRegistration([ requireSomeCapability(client, ClientCapability.Semantic), requireMinVersion(client, API.v570), - requireGlobalConfiguration(language.id, enabledSettingId), + requireGlobalUnifiedConfig(enabledSettingId, { fallbackSection: language.id }), ], () => { return vscode.languages.registerDocumentPasteEditProvider(selector.semantic, new DocumentPasteProvider(language.id, client, fileConfigurationManager), { providedPasteEditKinds: [DocumentPasteProvider.kind], diff --git a/extensions/typescript-language-features/src/languageFeatures/definitions.ts b/extensions/typescript-language-features/src/languageFeatures/definitions.ts index 76c5818be6c..b9e6979a887 100644 --- a/extensions/typescript-language-features/src/languageFeatures/definitions.ts +++ b/extensions/typescript-language-features/src/languageFeatures/definitions.ts @@ -9,6 +9,7 @@ import { API } from '../tsServer/api'; import * as typeConverters from '../typeConverters'; import { ClientCapability, ITypeScriptServiceClient } from '../typescriptService'; import DefinitionProviderBase from './definitionProviderBase'; +import { readUnifiedConfig } from '../utils/configuration'; import { conditionalRegistration, requireSomeCapability } from './util/dependentRegistration'; export default class TypeScriptDefinitionProvider extends DefinitionProviderBase implements vscode.DefinitionProvider { @@ -32,7 +33,7 @@ export default class TypeScriptDefinitionProvider extends DefinitionProviderBase const span = response.body.textSpan ? typeConverters.Range.fromTextSpan(response.body.textSpan) : undefined; let definitions = response.body.definitions; - if (vscode.workspace.getConfiguration(document.languageId).get('preferGoToSourceDefinition', false) && this.client.apiVersion.gte(API.v470)) { + if (readUnifiedConfig('preferGoToSourceDefinition', false, { scope: document, fallbackSection: document.languageId }) && this.client.apiVersion.gte(API.v470)) { const sourceDefinitionsResponse = await this.client.execute('findSourceDefinition', args, token); if (sourceDefinitionsResponse.type === 'response' && sourceDefinitionsResponse.body?.length) { definitions = sourceDefinitionsResponse.body; diff --git a/extensions/typescript-language-features/src/languageFeatures/tagClosing.ts b/extensions/typescript-language-features/src/languageFeatures/tagClosing.ts index 6b47feb3d00..a42ccbaddf6 100644 --- a/extensions/typescript-language-features/src/languageFeatures/tagClosing.ts +++ b/extensions/typescript-language-features/src/languageFeatures/tagClosing.ts @@ -10,6 +10,7 @@ import type * as Proto from '../tsServer/protocol/protocol'; import * as typeConverters from '../typeConverters'; import { ITypeScriptServiceClient } from '../typescriptService'; import { Disposable } from '../utils/dispose'; +import { readUnifiedConfig } from '../utils/configuration'; import { Condition, conditionalRegistration } from './util/dependentRegistration'; class TagClosing extends Disposable { @@ -149,7 +150,7 @@ function requireActiveDocumentSetting( return false; } - return !!vscode.workspace.getConfiguration(language.id, editor.document).get('autoClosingTags'); + return !!readUnifiedConfig('autoClosingTags.enabled', true, { scope: editor.document, fallbackSection: language.id, fallbackSubSectionNameOverride: 'autoClosingTags' }); }, handler => { return vscode.Disposable.from( diff --git a/extensions/typescript-language-features/src/languageFeatures/updatePathsOnRename.ts b/extensions/typescript-language-features/src/languageFeatures/updatePathsOnRename.ts index bdaa1fc69ff..761b13957e2 100644 --- a/extensions/typescript-language-features/src/languageFeatures/updatePathsOnRename.ts +++ b/extensions/typescript-language-features/src/languageFeatures/updatePathsOnRename.ts @@ -12,6 +12,7 @@ import * as typeConverters from '../typeConverters'; import { ClientCapability, ITypeScriptServiceClient } from '../typescriptService'; import { Delayer } from '../utils/async'; import { nulToken } from '../utils/cancellation'; +import { readUnifiedConfig } from '../utils/configuration'; import { Disposable } from '../utils/dispose'; import FileConfigurationManager from './fileConfigurationManager'; import { conditionalRegistration, requireSomeCapability } from './util/dependentRegistration'; @@ -65,8 +66,8 @@ class UpdateImportsOnFileRenameHandler extends Disposable { continue; } - const config = this.getConfiguration(newUri); - const setting = config.get(updateImportsOnFileMoveName); + const fallbackSection = doesResourceLookLikeATypeScriptFile(newUri) ? 'typescript' : 'javascript'; + const setting = readUnifiedConfig(updateImportsOnFileMoveName, UpdateImportsOnFileMoveSetting.Prompt, { scope: null, fallbackSection }); if (setting === UpdateImportsOnFileMoveSetting.Never) { continue; } @@ -122,8 +123,8 @@ class UpdateImportsOnFileRenameHandler extends Disposable { return false; } - const config = this.getConfiguration(newResources[0]); - const setting = config.get(updateImportsOnFileMoveName); + const fallbackSection = doesResourceLookLikeATypeScriptFile(newResources[0]) ? 'typescript' : 'javascript'; + const setting = readUnifiedConfig(updateImportsOnFileMoveName, UpdateImportsOnFileMoveSetting.Prompt, { scope: null, fallbackSection }); switch (setting) { case UpdateImportsOnFileMoveSetting.Always: return true; @@ -135,10 +136,6 @@ class UpdateImportsOnFileRenameHandler extends Disposable { } } - private getConfiguration(resource: vscode.Uri) { - return vscode.workspace.getConfiguration(doesResourceLookLikeATypeScriptFile(resource) ? 'typescript' : 'javascript', resource); - } - private async promptUser(newResources: readonly vscode.Uri[]): Promise { if (!newResources.length) { return false; @@ -177,7 +174,7 @@ class UpdateImportsOnFileRenameHandler extends Disposable { return false; } case alwaysItem: { - const config = this.getConfiguration(newResources[0]); + const config = vscode.workspace.getConfiguration('js/ts'); config.update( updateImportsOnFileMoveName, UpdateImportsOnFileMoveSetting.Always, @@ -185,7 +182,7 @@ class UpdateImportsOnFileRenameHandler extends Disposable { return true; } case neverItem: { - const config = this.getConfiguration(newResources[0]); + const config = vscode.workspace.getConfiguration('js/ts'); config.update( updateImportsOnFileMoveName, UpdateImportsOnFileMoveSetting.Never, diff --git a/extensions/typescript-language-features/src/languageFeatures/workspaceSymbols.ts b/extensions/typescript-language-features/src/languageFeatures/workspaceSymbols.ts index 24fb7068b74..d1b586a5a20 100644 --- a/extensions/typescript-language-features/src/languageFeatures/workspaceSymbols.ts +++ b/extensions/typescript-language-features/src/languageFeatures/workspaceSymbols.ts @@ -13,6 +13,7 @@ import * as PConst from '../tsServer/protocol/protocol.const'; import * as typeConverters from '../typeConverters'; import { ITypeScriptServiceClient } from '../typescriptService'; import { coalesce } from '../utils/arrays'; +import { readUnifiedConfig } from '../utils/configuration'; function getSymbolKind(item: Proto.NavtoItem): vscode.SymbolKind { switch (item.kind) { @@ -70,7 +71,7 @@ class TypeScriptWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvide private get searchAllOpenProjects() { return this.client.apiVersion.gte(API.v390) - && vscode.workspace.getConfiguration('typescript').get('workspaceSymbols.scope', 'allOpenProjects') === 'allOpenProjects'; + && readUnifiedConfig('workspaceSymbols.scope', 'allOpenProjects', { scope: null, fallbackSection: 'typescript' }) === 'allOpenProjects'; } private async toOpenedFiledPath(document: vscode.TextDocument) {