Skip to content

Commit

Permalink
simplify vscode extension title (#15519)
Browse files Browse the repository at this point in the history
  • Loading branch information
RiskyMH authored Dec 2, 2024
1 parent d2acb2e commit 56ad4cc
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
19 changes: 15 additions & 4 deletions packages/bun-vscode/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bun-vscode",
"version": "0.0.19",
"version": "0.0.22",
"author": "oven",
"repository": {
"type": "git",
Expand All @@ -21,7 +21,6 @@
"activationEvents": [
"onStartupFinished"
],
"browser": "dist/web-extension.js",
"bugs": {
"url": "https://github.com/oven-sh/bun/issues"
},
Expand All @@ -46,6 +45,18 @@
"scope": "window",
"default": null
},
"bun.diagnosticsSocket.enabled": {
"type": "boolean",
"description": "If Bun extension should communicate with Bun over a socket to show errors in editor.",
"scope": "window",
"default": true
},
"bun.bunlockb.enabled": {
"type": "boolean",
"description": "If visual lockfile viewer (`bun.lockb`) should be enabled ",
"scope": "window",
"default": true
},
"bun.debugTerminal.enabled": {
"type": "boolean",
"description": "If Bun should be added to the JavaScript Debug Terminal.",
Expand Down Expand Up @@ -321,7 +332,7 @@
]
},
"description": "The Visual Studio Code extension for Bun.",
"displayName": "Bun for Visual Studio Code",
"displayName": "Bun",
"engines": {
"vscode": "^1.60.0"
},
Expand Down Expand Up @@ -358,4 +369,4 @@
"../bun-debug-adapter-protocol",
"../bun-inspector-protocol"
]
}
}
4 changes: 4 additions & 0 deletions packages/bun-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ export function activate(context: vscode.ExtensionContext) {
// Only register for text editors
context.subscriptions.push(vscode.commands.registerTextEditorCommand("extension.bun.runUnsavedCode", runUnsavedCode));
}

export function getConfig<T>(path: string, scope?: vscode.ConfigurationScope) {
return vscode.workspace.getConfiguration("bun", scope).get<T>(path);
}
5 changes: 1 addition & 4 deletions packages/bun-vscode/src/features/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
UnixSignal,
WebSocketDebugAdapter,
} from "../../../bun-debug-adapter-protocol";
import { getConfig } from "../extension";

export const DEBUG_CONFIGURATION: vscode.DebugConfiguration = {
type: "bun",
Expand Down Expand Up @@ -372,10 +373,6 @@ function getRuntime(scope?: vscode.ConfigurationScope): string {
return "bun";
}

function getConfig<T>(path: string, scope?: vscode.ConfigurationScope) {
return vscode.workspace.getConfiguration("bun", scope).get<T>(path);
}

export async function runUnsavedCode() {
const editor = vscode.window.activeTextEditor;
if (!editor || !editor.document.isUntitled) return;
Expand Down
3 changes: 3 additions & 0 deletions packages/bun-vscode/src/features/diagnostics/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "../../../../bun-debug-adapter-protocol";
import type { JSC } from "../../../../bun-inspector-protocol";
import { typedGlobalState } from "../../global-state";
import { getConfig } from "../../extension";

const output = vscode.window.createOutputChannel("Bun - Diagnostics");

Expand Down Expand Up @@ -268,6 +269,8 @@ export async function registerDiagnosticsSocket(context: vscode.ExtensionContext
context.environmentVariableCollection.clear();
context.environmentVariableCollection.description = description;

if (!getConfig("diagnosticsSocket.enabled")) return;

const manager = await BunDiagnosticsManager.initialize(context);

context.environmentVariableCollection.replace("BUN_INSPECT_CONNECT_TO", manager.signalUrl);
Expand Down
6 changes: 6 additions & 0 deletions packages/bun-vscode/src/features/lockfile/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { spawn } from "node:child_process";
import * as vscode from "vscode";
import { styleLockfile } from "./lockfile.style";
import { getConfig } from "../../extension";

export type BunLockfile = vscode.CustomDocument & {
readonly preview: string;
Expand Down Expand Up @@ -36,6 +37,11 @@ export class BunLockfileEditorProvider implements vscode.CustomReadonlyEditorPro
}

function renderLockfile({ webview }: vscode.WebviewPanel, preview: string, extensionUri: vscode.Uri): void {
if (!getConfig("bunlockb.enabled")) {
webview.html = "<code>bun.bunlockb</code> config option is disabled."
return
}

const styleVSCodeUri = webview.asWebviewUri(vscode.Uri.joinPath(extensionUri, "assets", "vscode.css"));
const lockfileContent = styleLockfile(preview);

Expand Down
1 change: 1 addition & 0 deletions packages/bun-vscode/src/features/tasks/package.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import * as vscode from "vscode";
import { debugCommand } from "../debug";
import { BunTask } from "./tasks";
import { getConfig } from "../../extension";

/**
* Parses tasks defined in the package.json.
Expand Down

0 comments on commit 56ad4cc

Please sign in to comment.