Skip to content

Commit 626994c

Browse files
use Uri.joinPath to construct built-in notebook example Uri (#122)
in order to web-enable this extenion
1 parent e02b78d commit 626994c

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/extension/commands.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ import {
22
ExtensionContext,
33
Disposable,
44
QuickPickItem,
5-
ViewColumn,
65
Uri,
76
commands,
8-
window,
9-
workspace
7+
window
108
}
119
from 'vscode';
12-
import * as fs from 'fs';
13-
import * as path from 'path';
10+
1411
import * as config from './config';
1512
import * as constants from './constants';
1613

@@ -37,15 +34,15 @@ function registerCommand(commandName: string, callback: (...args: any[]) => any,
3734
description: notebook.type,
3835
detail: notebook.file
3936
}));
40-
const selectedNotebook: QuickPickItem | undefined =
37+
const selectedNotebook: QuickPickItem | undefined =
4138
await window.showQuickPick(notebookQuickPickItems, {canPickMany: false});
4239
if (selectedNotebook) {
4340
const notebookUrl: string | undefined = selectedNotebook.detail;
44-
const extensionPath: string = _context.asAbsolutePath('./');
41+
const extensionUri: Uri = _context.extensionUri;
4542
if (notebookUrl) {
46-
const notebookUri: Uri = Uri.file(path.join(extensionPath, notebookUrl));
43+
const notebookUri: Uri = Uri.joinPath(extensionUri, notebookUrl);
4744
// open data table example notebook
48-
commands.executeCommand(constants.VSCodeOpenCommand, notebookUri);
45+
commands.executeCommand(constants.VSCodeOpenCommand, notebookUri);
4946
}
5047
}
5148
}

src/extension/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
ExtensionContext
33
}
44
from 'vscode';
5+
56
import {registerCommands} from './commands';
67
import * as constants from './constants';
78

0 commit comments

Comments
 (0)