-
Notifications
You must be signed in to change notification settings - Fork 730
Fix Razor completion tooltip documentation #5839
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
Merged
allisonchou
merged 4 commits into
dotnet:main
from
allisonchou:dev/allichou/FixRazorDocBug
Jun 21, 2023
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weird... and probably against my understanding of typescript. We're casting to
vscode.MarkdownStringto make a new one? Does something magic happen in the constructor?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typescript seems to be weird in that we can have a
vscode.MarkdownStringbut the properties on the type may not be what is expected.For example, at the beginning of this method we get passed something that technically passes as a

vscode.MarkdownString, but has totally different properties:After the cast above and the creation of a new

MarkdownString, we're able to return the shape VS Code expects:Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this is actually wrong, but not in a way that makes a difference. I would guess that Roslyn LSP is returning the LSP type MarkupContent, which has a kind and a value. This code is casting it to a
vscode.MarkdownStringwhich also has a value, so it can read the value property without a compilation error. Since types, and therefore casts, don't really exist in the compiled JavaScript this works fine, as the property names we care about line up. The creation of the new markdown string is then really a conversion from the LSP type to the VS Code type.Since the LSP
documentationproperty isstring | MarkupContent, the real fix is probably to do a type check and see if it isMarkupContent, and if so convert toMarkdownString. If it's string it can be left alone, as the VS Code API isstring | MarkdownString, but item is typed asvscode.CompletionItemand not the LSP type, so I've no idea. Maybe that is wrong too?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate the insight! That would make sense actually. I pushed a change that checks for
MarkupContentinstead, it's a little hacky since we have to convert tounknownfirst, but it's probably better than what was there before.