-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ import { getUriPath } from '../UriPaths'; | |
| import { ProvisionalCompletionOrchestrator } from './ProvisionalCompletionOrchestrator'; | ||
| import { LanguageKind } from '../RPC/LanguageKind'; | ||
| import { RoslynLanguageServer } from '../../../lsptoolshost/roslynLanguageServer'; | ||
| import { CompletionItem, CompletionParams, CompletionTriggerKind } from 'vscode-languageclient'; | ||
| import { CompletionItem, CompletionList, CompletionParams, CompletionTriggerKind } from 'vscode-languageclient'; | ||
| import { UriConverter } from '../../../lsptoolshost/uriConverter'; | ||
| import * as RazorConventions from '../RazorConventions'; | ||
| import { MappingHelpers } from '../Mapping/MappingHelpers'; | ||
|
|
@@ -35,11 +35,6 @@ export class RazorCompletionItemProvider | |
|
|
||
| let completions: vscode.CompletionList | vscode.CompletionItem[]; | ||
|
|
||
| // For CSharp, completions need to keep the "data" field | ||
| // on the completion item for lazily resolving the edits in | ||
| // the resolveCompletionItem step. Using the vs code command | ||
| // drops that field because it doesn't exist in the declared vs code | ||
| // CompletionItem type. | ||
| if (language === LanguageKind.CSharp) { | ||
| const params: CompletionParams = { | ||
| context: { | ||
|
|
@@ -71,6 +66,13 @@ export class RazorCompletionItemProvider | |
| completions instanceof Array ? completions // was vscode.CompletionItem[] | ||
| : completions ? completions.items // was vscode.CompletionList | ||
| : []; | ||
|
|
||
| // For CSharp, completions need to keep the "data" field | ||
| // on the completion item for lazily resolving the edits in | ||
| // the resolveCompletionItem step. Using the vs code command | ||
| // drops that field because it doesn't exist in the declared vs code | ||
| // CompletionItem type. | ||
| const data = (<CompletionList>completions)?.itemDefaults?.data; | ||
|
|
||
| // There are times when the generated code will not line up with the content of the .razor/.cshtml file. | ||
| // Therefore, we need to offset all completion items' characters by a certain amount in order | ||
|
|
@@ -79,7 +81,7 @@ export class RazorCompletionItemProvider | |
| const completionCharacterOffset = projectedPosition.character - hostDocumentPosition.character; | ||
| for (const completionItem of completionItems) { | ||
| const doc = completionItem.documentation as vscode.MarkdownString; | ||
| if (doc) { | ||
| if (doc && doc.value) { | ||
| // Without this, the documentation doesn't get rendered in the editor. | ||
| const newDoc = new vscode.MarkdownString(doc.value); | ||
| newDoc.isTrusted = doc.isTrusted; | ||
|
|
@@ -128,6 +130,8 @@ export class RazorCompletionItemProvider | |
| completionItem.insertText = intellicodeCompletion.textEditText; | ||
| } | ||
| } | ||
|
|
||
| (<CompletionItem>completionItem).data = data; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this override the data with the default in all cases, even if the completion item has provided its own?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. afaik we shouldn't be modifying this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do need to explicitly set the Data property on the completion item in the case where C# returns to us a Data property that is only tied to the completion list.
Ah, good point - we shouldn't override if the completion item has provided its own Data property. Will push a change to fix this |
||
| } | ||
|
|
||
| const isIncomplete = completions instanceof Array ? false | ||
|
|
@@ -204,6 +208,13 @@ export class RazorCompletionItemProvider | |
|
|
||
| item = newItem; | ||
|
|
||
| // The documentation object Roslyn returns can have a different | ||
| // shape than what the client expects, so we do a conversion here. | ||
| const markdownString = <vscode.MarkdownString>(item.documentation); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typescript seems to be weird in that we can have a For example, at the beginning of this method we get passed something that technically passes as a After the cast above and the creation of a new
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Since the LSP
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| if (markdownString && markdownString.value) { | ||
| item.documentation = new vscode.MarkdownString(markdownString.value); | ||
| } | ||
|
|
||
| if (item.command && item.command.arguments?.length === 4) { | ||
| let uri = vscode.Uri.parse(item.command.arguments[0]); | ||
|
|
||
|
|
@@ -238,4 +249,3 @@ function getTriggerKind(triggerKind: vscode.CompletionTriggerKind): CompletionTr | |
|
|
||
| } | ||
| } | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.