Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add configurable maximum hover length #61662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

gabritto
Copy link
Member

@gabritto gabritto commented May 5, 2025

Fixes #35601.
Fixes #26238.

This PR adds a user preference for configuring the maximum truncation length of a quickinfo/hover text.
Note that this only affects truncation during hover. Truncation during everything else still uses the same defaults.
This also fixes #26238 because we now always provide a truncation length to quickinfo that is independent from the compiler option noErrorTruncation.
I think the intention of noErrorTruncation was always to enable/disable truncation in diagnostics, but incidentally it affected everything that happened to use typeToString.

vscode PR: 248181

Note:
This and the vscode PRs set the maximum hover length to 500 by default. The previous default was 160.
This is almost a random number based on my experience of using expandable hover and feeling that 160 is way too low.

@typescript-bot
Copy link
Collaborator

Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page.

Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up.

@gabritto gabritto marked this pull request as ready for review May 6, 2025 01:01
@Copilot Copilot AI review requested due to automatic review settings May 6, 2025 01:01
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a user preference to configure the maximum truncation length for hover quickinfo, decoupling hover truncation from the diagnostic-only behavior controlled by the “noErrorTruncation” compiler option. Key changes include updating the signatures of quickinfo‐related functions across the codebase (including services, compiler utilities, and tests), adding a new default hover maximum length, and adjusting tests to verify the updated truncation output.

Reviewed Changes

Copilot reviewed 20 out of 22 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/cases/fourslash/quickinfoVerbosityTruncation*.ts Added/updated tests to include the maximum truncation length parameter in quickinfo baseline verification
tests/cases/fourslash/quickInfoCanBeTruncated.ts Updated expected quickinfo output for long union types reflecting expanded truncation behavior
src/services/utilities.ts Updated display part writer creation to cache based on the new maximumLength parameter
src/services/types.ts Modified getQuickInfoAtPosition API to include the new maximumLength parameter
src/services/symbolDisplay.ts Propagated maximumLength parameter to type/symbol formatting functions
src/services/services.ts, src/server/session.ts Updated quickinfo function calls to appropriately pass the new maximumLength value
src/harness/* Adjusted fourslash harness functions to support maximum hover length configuration
src/compiler/utilities.ts Defined defaultHoverMaximumTruncationLength and updated file emit utilities
src/compiler/types.ts Updated internal signature and type formatting functions to support the new maximumLength parameter
Files not reviewed (2)
  • tests/baselines/reference/quickinfoVerbosityToplevelTruncation1.baseline: Language not supported
  • tests/baselines/reference/quickinfoVerbosityTruncation1.baseline: Language not supported
Comments suppressed due to low confidence (2)

src/services/types.ts:585

  • Ensure that the overloads for getQuickInfoAtPosition remain backward compatible by properly handling the new maximumLength parameter in both the public and internal signatures.
getQuickInfoAtPosition(fileName: string, position: number, maximumLength?: number, verbosityLevel?: number): QuickInfo | undefined;

src/compiler/types.ts:5187

  • Confirm that adding the maximumLength parameter in writeSignature (and related functions such as writeType) integrates smoothly with the existing type formatting logic and does not alter legacy behavior unexpectedly.
writeSignature(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind, writer?: EmitTextWriter, maximumLength?: number, verbosityLevel?: number, out?: WriterContextOut): string;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Backlog Bug PRs that fix a backlog bug
Projects
None yet
2 participants