refactor config path

This commit is contained in:
Gabriela Araujo Britto
2025-05-07 11:31:47 -07:00
parent c2822f848d
commit 56e2f3c5c4
3 changed files with 7 additions and 13 deletions

View File

@@ -481,17 +481,11 @@
"experimental"
]
},
"typescript.maximumHoverLength": {
"js/ts.hover.maximumLength": {
"type": "number",
"default": 500,
"description": "%configuration.maximumHoverLength%",
"scope": "window"
},
"javascript.maximumHoverLength": {
"type": "number",
"default": 500,
"description": "%configuration.maximumHoverLength%",
"scope": "window"
"description": "%configuration.hover.maximumLength%",
"scope": "resource"
}
}
},

View File

@@ -231,7 +231,7 @@
"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.expandableHover": "Enable expanding/contracting the hover to reveal more/less information from the TS server. Requires TypeScript 5.9+.",
"configuration.maximumHoverLength": "The maximum number of characters in a hover. If the hover is longer than this, it will be truncated. Requires TypeScript 5.9+.",
"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.",
"walkthroughs.nodejsWelcome.downloadNode.forMacOrWindows.title": "Install Node.js",

View File

@@ -209,7 +209,7 @@ export default class FileConfigurationManager extends Disposable {
...getInlayHintsPreferences(config),
...this.getOrganizeImportsPreferences(preferencesConfig),
// @ts-expect-error until TS 5.9
maximumHoverLength: this.getMaximumHoverLength(config),
maximumHoverLength: this.getMaximumHoverLength(document),
};
return preferences;
@@ -261,9 +261,9 @@ export default class FileConfigurationManager extends Disposable {
}
private getMaximumHoverLength(configuration: vscode.WorkspaceConfiguration): number {
private getMaximumHoverLength(document: vscode.TextDocument): number {
const defaultMaxLength = 500;
const maximumHoverLength = configuration.get<number>('maximumHoverLength', defaultMaxLength);
const maximumHoverLength = vscode.workspace.getConfiguration('js/ts', document).get<number>('maximumHoverLength', defaultMaxLength);
if (!Number.isSafeInteger(maximumHoverLength) || maximumHoverLength <= 0) {
return defaultMaxLength;
}