Skip to content

Commit

Permalink
feat(vscode): allow clickable links on hover for type descriptions (#404
Browse files Browse the repository at this point in the history
)

* feat(vscode): allow clickable links in type descriptions

* Update comment
  • Loading branch information
christianvuerings authored May 28, 2021
1 parent 10be374 commit 1a43503
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions lib/flowLSP/FlowLanguageClient/createMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import * as vscode from 'vscode';
import * as lsp from '../utils/LanguageClient';
import FlowconfigCache from '../utils/FlowconfigCache';
import formatMarkedDownString from '../utils/formatMarkedDownString';
import formatFlowMarkDownString from '../utils/formatFlowMarkDownString';
import checkFlowVersionSatisfies from '../utils/checkFlowVersionSatisifies';

export default function createMiddleware(
Expand Down Expand Up @@ -207,9 +207,12 @@ function formatHoverContent(value: ?vscode.Hover): ?vscode.Hover {

// format content
value.contents = value.contents.map((content) => {
// NOTE: in our case, content is always MarkdownString
if (content instanceof vscode.MarkdownString) {
return formatMarkedDownString(content);
// NOTE: only re-format a flow specific MarkdownString so we preserve markdown in type comments
if (
content instanceof vscode.MarkdownString &&
content.value.includes('```flow')
) {
return formatFlowMarkDownString(content);
}
return content;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as vscode from 'vscode';
import format from '../../common/format';

export default function formatMarkedDownString(
export default function formatFlowMarkDownString(
mdStr: vscode.MarkdownString,
): vscode.MarkdownString {
const code = extractCode(mdStr, 'flow');
Expand Down

0 comments on commit 1a43503

Please sign in to comment.