Skip to content

Commit a4cfa9f

Browse files
committed
Fix Go to Super Implementation hover link not clickable (#4438)
The command-link sanitization added in fixJdtSchemeHoverLinks stripped all [label](command:...) links, including the trusted ones the extension contributes (e.g. Go to Super Implementation). Skip sanitizing trusted contributed content; only untrusted server Javadoc is sanitized.
1 parent 6109b9a commit a4cfa9f

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/hoverAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class JavaHoverProvider implements HoverProvider {
7474
}
7575

7676
const contributed = new MarkdownString(contributedCommands.map((command) => this.convertCommandToMarkdown(command)).join(' | '));
77-
contributed.isTrusted = true;
77+
contributed.isTrusted = { enabledCommands: contributedCommands.map((command) => command.command) };
7878
let contents: MarkdownString[] = [ contributed ];
7979
let range;
8080
if (serverHover && serverHover.contents) {

src/providerDispatcher.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,13 @@ export function fixJdtSchemeHoverLinks(hover: Hover): Hover {
211211
const newContents: (MarkedString | MarkdownString)[] = [];
212212
for (const content of hover.contents) {
213213
if (content instanceof MarkdownString) {
214-
newContents.push(fixJdtLinksInDocumentation(content));
214+
// Skip our own trusted contributed commands (e.g. "Go to Super Implementation");
215+
// only sanitize untrusted server-provided Javadoc.
216+
if (content.isTrusted) {
217+
newContents.push(content);
218+
} else {
219+
newContents.push(fixJdtLinksInDocumentation(content));
220+
}
215221
} else {
216222
newContents.push(content);
217223
}

0 commit comments

Comments
 (0)