Skip to content
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

Discussion: Syntax highlighting for CompletionEntryDetails displayParts #19052

Closed
mjbvz opened this issue Oct 9, 2017 · 4 comments
Closed

Discussion: Syntax highlighting for CompletionEntryDetails displayParts #19052

mjbvz opened this issue Oct 9, 2017 · 4 comments
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Oct 9, 2017

Problem
With microsoft/vscode#34188, we are looking to add syntax highlighting to the detail section of VS Code's documentation. Currently we use the displayParts field on the CompletionEntryDetails response for this. However the returned display parts are not always valid TS/JS code blocks, resulting in incorrect colorization in some cases:

screen shot 2017-10-09 at 2 54 29 pm

In this example, const should be blue. The unclosed interface causes it to be colored incorrectly.

TypeScript currently returns basic token info using the SymbolDisplayPart type, however we cannot use this in a VS Code extension for colorization

Proposal
In the Date example, there are really two blocks of code:

interface Date

and

const Date: DateConstructor

The first block is the primary label for the item while the other block provides additional info. Other completion items may have more than two sections.

I propose adding a new additionalDetails field to CompletionEntryDetails as follows:

interface CompletionEntryDetails {
    ...
    displayParts: SymbolDisplayPart[];
    additionalDisplayParts?: SymbolDisplayPart[][];
}
  • displayParts would contain the primary label for the item, such as interface Date. I imagine this should always match what we return for quick info on the symbol
  • additionalDisplayParts would be an optional set of additional code blocks to display, such as const Date: DateConstructor. Each code block would be syntax highlighted on its own

This change would be mostly backwards compatible, however older clients that do not support additionalDisplayParts could lose some display information

Any other thoughts on how we could implement this?

@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Oct 9, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Jul 12, 2018

@sheetalkamat any thoughts on how we can make this simpler for VSCode?

@mhegazy mhegazy added the Needs Investigation This issue needs a team member to investigate its status. label Jul 12, 2018
@mhegazy mhegazy added this to the TypeScript 3.1 milestone Jul 12, 2018
@mhegazy mhegazy added the Suggestion An idea for TypeScript label Jul 12, 2018
@sheetalkamat
Copy link
Member

@mjbvz Wont you be directly be able to map SymbolDisplayPartKind to tm scope instead of using extension to get the scopes?

@weswigham weswigham added the In Discussion Not yet reached consensus label Nov 6, 2018
@RyanCavanaugh RyanCavanaugh removed In Discussion Not yet reached consensus Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue labels Jul 16, 2019
@sheetalkamat
Copy link
Member

@mjbvz do we still need this?

@mjbvz
Copy link
Contributor Author

mjbvz commented Sep 26, 2019

We still don't have a good story for this on the VS Code side so I'll close this. We may revisit this sometime in the future since it would be nice to have, but we need to figure out how we want to support it in VS Code

@mjbvz mjbvz closed this as completed Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

6 participants