Skip to content
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

bugfix: Don't show panel if unable to parse release notes #1565

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions packages/metals-vscode/src/releaseNotesProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ async function showReleaseNotesImpl(
// below are helper functions

async function showPanel(version: string, releaseNotesUrl: string) {
const releaseNotes = await getReleaseNotesMarkdown(releaseNotesUrl);

const panel = vscode.window.createWebviewPanel(
`scalameta.metals.whatsNew`,
`Metals ${version} release notes`,
Expand All @@ -76,13 +78,17 @@ async function showReleaseNotesImpl(
path.join(context.extensionPath, "icons", "scalameta-logo.png")
);

const releaseNotes = await getReleaseNotesMarkdown(
releaseNotesUrl,
context,
(uri) => panel.webview.asWebviewUri(uri)
// Uri with additional styles for webview
const stylesPathMainPath = vscode.Uri.joinPath(
context.extensionUri,
"media",
"styles.css"
);

panel.webview.html = releaseNotes;
// need to transform Uri
const stylesUri = panel.webview.asWebviewUri(stylesPathMainPath);

panel.webview.html = releaseNotes(stylesUri);
panel.reveal();

// Update current device's latest server version when there's no value or it was a older one.
Expand Down Expand Up @@ -194,10 +200,8 @@ async function getMarkdownLink(
* proxy to webview.asWebviewUri
*/
async function getReleaseNotesMarkdown(
releaseNotesUrl: string,
context: ExtensionContext,
asWebviewUri: (_: vscode.Uri) => vscode.Uri
): Promise<string> {
releaseNotesUrl: string
): Promise<(_: vscode.Uri) => string> {
const text = await fetchFrom(releaseNotesUrl);
// every release notes starts with metadata format
const tripleDash = "---";
Expand All @@ -218,16 +222,7 @@ async function getReleaseNotesMarkdown(
const authorUrl = metadata[2].slice("authorURL: ".length);
const renderedNotes = marked.parse(releaseNotes);

// Uri with additional styles for webview
const stylesPathMainPath = vscode.Uri.joinPath(
context.extensionUri,
"media",
"styles.css"
);
// need to transform Uri
const stylesUri = asWebviewUri(stylesPathMainPath);

return `
return (stylesUri: vscode.Uri) => `
<!DOCTYPE html>
<html lang="en" style="height: 100%; width: 100%;">
<head>
Expand Down
Loading