Skip to content

Don't use code annotations unconditionally for related diagnostics - #49319

Merged
Johannes Rieken (jrieken) merged 2 commits into
microsoft:masterfrom
Xanewok:related-information-markdown
May 7, 2018
Merged

Johannes Rieken (jrieken) merged 2 commits into
microsoft:masterfrom
Xanewok:related-information-markdown

Conversation

@Xanewok

Copy link
Copy Markdown
Contributor

Apparently fixes #46713.

First of all, thank you for your work on related information! That seems like a huge boon for Rust users, where the diagnostics emitted by the compiler often have multiple spans. It's nifty to see them logically grouped in VSCode!

I noticed that the related information messages unconditionally use code formatting. That doesn't seem consistent with regular diagnostic messages and also rustc emits messages containing backticks when referring to code, which would benefit further from using the message verbatim.

I tried to nail it down, the effects can be seen here:

Before:
before_change

After:
after_change

Is the fix good or should we sanitize and disable markdown rendering for related information, like it's done for primary diagnostic message? (It'd be great to opt-in into primary diagnostic message rendered as markdown as well, but that's another thing)

@jrieken

Copy link
Copy Markdown
Contributor

Looking good. Thanks.

Is the fix good or should we sanitize and disable markdown rendering for related information, like it's done for primary diagnostic message? (It'd be great to opt-in into primary diagnostic message rendered as markdown as well, but that's another thing)

Yeah, I think for now VS Code should escape markdown syntax because the type is just a string. The API does spec the MarkdownString-type and there are ideas to allow that for diagnostics.

@jrieken

Copy link
Copy Markdown
Contributor

Is the fix good or should we sanitize and disable markdown rendering for related information,

And yeah, I think we should sanitise and if you wanna update this PR that would be awesome. We don't have a reusable util-function but this: https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/api/node/extHostTypes.ts#L983 from which you could do some copying.

@jrieken

Copy link
Copy Markdown
Contributor

have a reusable util-function but this: https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/api/node/extHostTypes.ts#L983 from which you could do some copying.

I was lying... You can use appendText in that context. It will do the escaping for you...

@Xanewok

Copy link
Copy Markdown
Contributor Author

Done!

escaped

`* [${basename(resource.path)}(${startLineNumber}, ${startColumn})](${resource.toString(false)}#${startLineNumber},${startColumn}): ${message} \n`
`* [${basename(resource.path)}(${startLineNumber}, ${startColumn})](${resource.toString(false)}#${startLineNumber},${startColumn}): `
);
hoverMessage.appendText(`${message}`);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Uh, I just realized - I guess this could be just written as hoverMessage.appendText(message);?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fair enough.

@jrieken

Copy link
Copy Markdown
Contributor

Merging, looking good. Thanks 👏

@jrieken
Johannes Rieken (jrieken) merged commit ff7b9d9 into microsoft:master May 7, 2018
@Xanewok

Copy link
Copy Markdown
Contributor Author

Thanks!

@Xanewok
Igor Matuszewski (Xanewok) deleted the related-information-markdown branch May 7, 2018 08:30
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Related information hover message background should not differ

2 participants