Skip to content

Commit c2f1cff

Browse files
Merge pull request #4 from Maan2003/master
Enhancement: Add comments
2 parents 3549d17 + c222520 commit c2f1cff

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

extension/CHANGELOG.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

extension/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
"Other"
1111
],
1212
"activationEvents": [
13-
"onCommand:p5-complete.addComp"
13+
"onCommand:p5-complete.openSketch"
1414
],
1515
"main": "./out/extension.js",
1616
"contributes": {
1717
"commands": [
1818
{
19-
"command": "p5-complete.addComp",
19+
"command": "p5-complete.openSketch",
2020
"title": "Open this sketch"
2121
}
2222
]

extension/src/extension.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,44 @@ import * as path from 'path';
66
// this method is called when your extension is activated
77
// your extension is activated the very first time the command is executed
88
export function activate(context: vscode.ExtensionContext) {
9-
let disposable = vscode.commands.registerCommand('p5-complete.addComp', async () => {
9+
10+
// register the command with vscode.
11+
// so that we can run it from command pallete.
12+
// this command is also defined in package.json
13+
let disposable = vscode.commands.registerCommand("p5-complete.openSketch", async () => {
14+
15+
// create a new webview
16+
// this is used to show the sketch
1017
const panel = vscode.window.createWebviewPanel(
1118
"p5Sketch",
1219
"p5 Sketch",
20+
// use split mode
1321
vscode.ViewColumn.Two,
1422
{
23+
// enable javascript
1524
enableScripts: true,
1625
}
1726
)
1827

28+
// find all the javascript files in the workspace
1929
const files = await vscode.workspace.findFiles("*.js");
20-
// push index.js to last
21-
30+
31+
// map the files to script tag
2232
const scripts = files.map(file => {
2333
const path = panel.webview.asWebviewUri(file).toString();
2434
return `<script src="${path}"></script>`
2535
}).join("");
26-
27-
const p = vscode.Uri.file(path.join(context.extensionPath,"p5.js"));
28-
const p5Path = panel.webview.asWebviewUri(p);
29-
3036

37+
// get url of p5.js file
38+
const p5Path = panel.webview.asWebviewUri(
39+
vscode.Uri.file(path.join(context.extensionPath, "p5.js"))
40+
);
41+
42+
// add everything to html content of webview
3143
panel.webview.html = `<script src="${p5Path}"></script>${scripts}`
3244
});
3345

46+
// I don't know
3447
context.subscriptions.push(disposable);
3548
}
3649

0 commit comments

Comments
 (0)