diff options
author | 2023-09-20 19:09:51 +0200 | |
---|---|---|
committer | 2023-09-20 10:09:51 -0700 | |
commit | 711a2bcdd1a6bb7ab9029625b28517254cfdcd3e (patch) | |
tree | b3ac0565bc5c7eb4c5a2bb03885300eb76bd7b3a | |
parent | 689b28455c943897a3d286271e6f182afb17848f (diff) | |
download | bun-711a2bcdd1a6bb7ab9029625b28517254cfdcd3e.tar.gz bun-711a2bcdd1a6bb7ab9029625b28517254cfdcd3e.tar.zst bun-711a2bcdd1a6bb7ab9029625b28517254cfdcd3e.zip |
Fix various bugs in vscode extension (#5772)
* Fix bugs
* Fix bugs
* Revert "Fix bugs"
This reverts commit 608639eb2214fdf4310477051ce47d20702b5dd0.
-rw-r--r-- | packages/bun-vscode/assets/vscode.css | 70 | ||||
-rw-r--r-- | packages/bun-vscode/example/package.json | 6 | ||||
-rw-r--r-- | packages/bun-vscode/src/features/tasks/package.json.ts | 18 |
3 files changed, 85 insertions, 9 deletions
diff --git a/packages/bun-vscode/assets/vscode.css b/packages/bun-vscode/assets/vscode.css new file mode 100644 index 000000000..4420d06e8 --- /dev/null +++ b/packages/bun-vscode/assets/vscode.css @@ -0,0 +1,70 @@ +.mtk1 { color: #cccccc; } +.mtk2 { color: #1f1f1f; } +.mtk3 { color: #d4d4d4; } +.mtk4 { color: #000080; } +.mtk5 { color: #6a9955; } +.mtk6 { color: #569cd6; } +.mtk7 { color: #b5cea8; } +.mtk8 { color: #646695; } +.mtk9 { color: #d7ba7d; } +.mtk10 { color: #9cdcfe; } +.mtk11 { color: #f44747; } +.mtk12 { color: #ce9178; } +.mtk13 { color: #6796e6; } +.mtk14 { color: #808080; } +.mtk15 { color: #d16969; } +.mtk16 { color: #dcdcaa; } +.mtk17 { color: #4ec9b0; } +.mtk18 { color: #c586c0; } +.mtk19 { color: #4fc1ff; } +.mtk20 { color: #c8c8c8; } +.mtk21 { color: #606060; } +.mtk22 { color: #ffffff; } +.mtk23 { color: #cd9731; } +.mtk24 { color: #b267e6; } +.mtki { font-style: italic; } +.mtkb { font-weight: bold; } +.mtku { text-decoration: underline; text-underline-position: under; } +.mtks { text-decoration: line-through; } +.mtks.mtku { text-decoration: underline line-through; text-underline-position: under; } + + + +.bunlock { + display: flex; + flex-direction: row; +} + +.lines { + display: flex; + flex-direction: column; + width: 30px; + margin-right: 15px; + text-align: right; + opacity: 0.5; + + font-size: var(--vscode-editor-font-size); + font-weight: var(--vscode-editor-font-weight); + font-family: var(--vscode-editor-font-family); + background-color: var(--vscode-editor-background); +} +.lines > span { + margin-top: 1px; + margin-bottom: 1px; +} + +code { + white-space: pre; + + font-size: var(--vscode-editor-font-size); + font-weight: var(--vscode-editor-font-weight); + font-family: var(--vscode-editor-font-family); + background-color: var(--vscode-editor-background); +} + +code > span { + display: inline-block; + width: 100%; + margin-top: 1px; + margin-bottom: 1px; +}
\ No newline at end of file diff --git a/packages/bun-vscode/example/package.json b/packages/bun-vscode/example/package.json index 91055b5f5..eed10159d 100644 --- a/packages/bun-vscode/example/package.json +++ b/packages/bun-vscode/example/package.json @@ -8,8 +8,10 @@ "mime-db": "^1.52.0" }, "scripts": { - "run": "hello.js", - "start": "bun hello.js" + "run": "node hello.js", + "start": "hello.js", + "start:bun": "bun hello.js", + "start:bun:quotes": "bun run hello.js" }, "trustedDependencies": [ "mime" diff --git a/packages/bun-vscode/src/features/tasks/package.json.ts b/packages/bun-vscode/src/features/tasks/package.json.ts index 764ea9712..3f04fa25d 100644 --- a/packages/bun-vscode/src/features/tasks/package.json.ts +++ b/packages/bun-vscode/src/features/tasks/package.json.ts @@ -25,7 +25,7 @@ export async function providePackageJsonTasks(): Promise<BunTask[]> { return Object.entries(scripts).map(([name, script]) => { // Prefix script with bun if it doesn't already start with bun - const shellCommand = script.startsWith("bun") ? script : `bun ${script}`; + const shellCommand = script.startsWith("bun run ") ? script : `bun run ${script}`; const task = new BunTask({ script, @@ -55,10 +55,12 @@ function extractScriptsFromPackageJson(document: vscode.TextDocument) { const range = new vscode.Range(document.positionAt(startIndex), document.positionAt(endIndex)); const scripts = matches[1].split(/,\s*/).map(script => { - const [name, command] = script.split(/s*:\s*/); + const elements = script.match(/"([^"\\]|\\.|\\\n)*"/g) + if(elements?.length != 2) return null + const [name, command] = elements return { - name: name.replace(/"/g, "").trim(), - command: command.replace(/"/g, "").trim(), + name: name.replace('"', "").trim(), + command: command.replace(/(?<!\\)"/g, "").trim(), range: new vscode.Range( document.positionAt(startIndex + matches[0].indexOf(name)), document.positionAt(startIndex + matches[0].indexOf(name) + name.length + command.length), @@ -175,23 +177,25 @@ function registerHoverProvider(context: vscode.ExtensionContext) { }, }), vscode.commands.registerCommand("extension.bun.codelens.debug.task", async ({ script, name }: CommandArgs) => { + if (script.startsWith("bun run ")) script = script.slice(8); if (script.startsWith("bun ")) script = script.slice(4); + debugCommand(script); }), vscode.commands.registerCommand("extension.bun.codelens.run.task", async ({ script, name }: CommandArgs) => { - if (script.startsWith("bun ")) script = script.slice(4); + if (script.startsWith("bun run ")) script = script.slice(8); name = `Bun Task: ${name}`; const terminals = getActiveTerminal(name); if (terminals.length > 0) { terminals[0].show(); - terminals[0].sendText(`bun ${script}`); + terminals[0].sendText(`bun run ${script}`); return; } const terminal = vscode.window.createTerminal({ name }); terminal.show(); - terminal.sendText(`bun ${script}`); + terminal.sendText(`bun run ${script}`); }), ); } |