Skip to content

Commit

Permalink
Closes #85579 - adds codicons to hovers
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Amodio committed Nov 26, 2019
1 parent e1edd6b commit d94edc8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/vs/base/browser/markdownRenderer.ts
Expand Up @@ -15,12 +15,15 @@ import { cloneAndChange } from 'vs/base/common/objects';
import { escape } from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network';
import { renderCodicons } from 'vs/base/browser/ui/codiconLabel/codiconLabel';

export interface MarkdownRenderOptions extends FormattedTextRenderOptions {
codeBlockRenderer?: (modeId: string, value: string) => Promise<string>;
codeBlockRenderCallback?: () => void;
}

const codiconsRegex = /^codicon:\/\/(.*)$/;

/**
* Create html nodes for the given content element.
*/
Expand Down Expand Up @@ -72,6 +75,13 @@ export function renderMarkdown(markdown: IMarkdownString, options: MarkdownRende

const renderer = new marked.Renderer();
renderer.image = (href: string, title: string, text: string) => {
if (href) {
const match = codiconsRegex.exec(href);
if (match !== null) {
return renderCodicons(match[1]);
}
}

let dimensions: string[] = [];
let attributes: string[] = [];
if (href) {
Expand Down Expand Up @@ -185,7 +195,8 @@ export function renderMarkdown(markdown: IMarkdownString, options: MarkdownRende
'a': ['href', 'name', 'target', 'data-href'],
'iframe': ['allowfullscreen', 'frameborder', 'src'],
'img': ['src', 'title', 'alt', 'width', 'height'],
'div': ['class', 'data-code']
'div': ['class', 'data-code'],
'span': ['class']
}
});

Expand Down
6 changes: 6 additions & 0 deletions src/vs/editor/contrib/hover/hover.css
Expand Up @@ -104,3 +104,9 @@
.monaco-editor-hover .hover-row.status-bar .actions .action-container .action .icon {
padding-right: 4px;
}

.monaco-editor-hover .markdown-hover .hover-contents .codicon {
color: inherit;
font-size: inherit;
vertical-align: middle;
}

0 comments on commit d94edc8

Please sign in to comment.