Skip to content

Commit 7ef9cdd

Browse files
authored
Merge pull request #248181 from gabritto/hoverlimit
[typescript-language-features] Add configuration for maximum hover length
2 parents 0a135e9 + 300ecf7 commit 7ef9cdd

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

extensions/typescript-language-features/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,12 @@
466466
"tags": [
467467
"experimental"
468468
]
469+
},
470+
"js/ts.hover.maximumLength": {
471+
"type": "number",
472+
"default": 500,
473+
"description": "%configuration.hover.maximumLength%",
474+
"scope": "resource"
469475
}
470476
}
471477
},

extensions/typescript-language-features/package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@
226226
"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.",
227227
"configuration.updateImportsOnPaste": "Automatically update imports when pasting code. Requires TypeScript 5.6+.",
228228
"configuration.expandableHover": "Enable expanding/contracting the hover to reveal more/less information from the TS server. Requires TypeScript 5.9+.",
229+
"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+.",
229230
"walkthroughs.nodejsWelcome.title": "Get started with JavaScript and Node.js",
230231
"walkthroughs.nodejsWelcome.description": "Make the most of Visual Studio Code's first-class JavaScript experience.",
231232
"walkthroughs.nodejsWelcome.downloadNode.forMacOrWindows.title": "Install Node.js",

extensions/typescript-language-features/src/languageFeatures/fileConfigurationManager.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ export default class FileConfigurationManager extends Disposable {
208208
includeCompletionsForModuleExports: config.get<boolean>('suggest.autoImports'),
209209
...getInlayHintsPreferences(config),
210210
...this.getOrganizeImportsPreferences(preferencesConfig),
211+
// @ts-expect-error until TS 5.9
212+
maximumHoverLength: this.getMaximumHoverLength(document),
211213
};
212214

213215
return preferences;
@@ -257,6 +259,16 @@ export default class FileConfigurationManager extends Disposable {
257259
} : {}),
258260
};
259261
}
262+
263+
264+
private getMaximumHoverLength(document: vscode.TextDocument): number {
265+
const defaultMaxLength = 500;
266+
const maximumHoverLength = vscode.workspace.getConfiguration('js/ts', document).get<number>('hover.maximumLength', defaultMaxLength);
267+
if (!Number.isSafeInteger(maximumHoverLength) || maximumHoverLength <= 0) {
268+
return defaultMaxLength;
269+
}
270+
return maximumHoverLength;
271+
}
260272
}
261273

262274
function withDefaultAsUndefined<T, O extends T>(value: T, def: O): Exclude<T, O> | undefined {

0 commit comments

Comments
 (0)