-
Notifications
You must be signed in to change notification settings - Fork 32.6k
special characters (<,>,&) not rendered correctly in intellisense preview #65956
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
Comments
@jrieken I was assuming we do not support markdown strings in diagnostic message? Was it leaking somehow before? |
Is this really a diagnostic message and not just a hover? |
It is a diagnostic message like follow
|
Ok, I see the issue. It is because, I am rendering the diagnostic message as markdown and I am escaping the string only for html content. Strangely markdown renderer is not rendering markdown tags always but only some times. For example
Markdown tag (tick) is not considered in above case where as it is in following
|
AnalysisIn order to have nice hover for a diagnostic, I was generating the html and sending it using markdown string. While doing this, I am escaping the message, but the markdown tags are not escaped and they are getting rendered. FixQuick and safe fix is to revert the above change. The proper fix would be is to move diagnostic hover rendering as an editor contribution. Otherwise, it is quiet impossible to generate a model hover decoration for a diagnostic that shows message and details (source+code) nicely as I can only provide string or markdown string. |
@sandy081 I just tested this in 61122f8 with the following extension: import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
vscode.languages.registerHoverProvider('markdown', new Provider())
}
class Provider implements vscode.HoverProvider {
provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): vscode.ProviderResult<vscode.Hover> {
return new vscode.Hover("std::option::Option<std::string::String> found type std::option::Option<&std::string::String>");
}
} I still see the content being treated as markdown: |
Fix is for Diagnostic messages and not for hover providers. Please verify using a diagnostic provider. 'use strict';
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
const diagnosticsCollection = vscode.languages.createDiagnosticCollection('test');
vscode.window.onDidChangeActiveTextEditor(e => {
if (e && e.document) {
const diagnostics: vscode.Diagnostic[] = [];
let message = "std::option::Option<std::string::String> found type std::option::Option<&std::string::String>";
const diagnostic = new vscode.Diagnostic(new vscode.Range(new vscode.Position(10, 1), new vscode.Position(10, 10)), message, vscode.DiagnosticSeverity.Error);
diagnostic.source = 'test';
diagnostic.code = 'something';
diagnostics.push(diagnostic);
diagnosticsCollection.set(e.document.uri, diagnostics);
}
});
}
// this method is called when your extension is deactivated
export function deactivate() {
} |
We used backtick-enclosed strings for types and since everything is escaped now to render a custom hover window, the error messages are illegible now, for example:
current output
note: expected type
std::option::Option<std::string::String>
found typestd::option::Option<&std::string::String>
previous output
note: expected type
std::option::Option<std::string::String>
found typestd::option::Option<&std::string::String>
Ref - rust-lang/vscode-rust#479
Regression from #62370
The text was updated successfully, but these errors were encountered: