aboutsummaryrefslogtreecommitdiff
path: root/packages/bun-debug-adapter-protocol/src/debugger/adapter.ts
diff options
context:
space:
mode:
authorGravatar Ashcon Partovi <ashcon@partovi.net> 2023-08-26 01:38:31 -0700
committerGravatar Ashcon Partovi <ashcon@partovi.net> 2023-08-26 01:38:31 -0700
commitf9b966c13f5ed3d870c54b69cb59a5adc12060b7 (patch)
treea607dee9d5ac97d71e765e996d6a733cd782fdc8 /packages/bun-debug-adapter-protocol/src/debugger/adapter.ts
parentd2ad4da1a03eb00a64a73abf3f6d6cf7dbd9be88 (diff)
downloadbun-f9b966c13f5ed3d870c54b69cb59a5adc12060b7.tar.gz
bun-f9b966c13f5ed3d870c54b69cb59a5adc12060b7.tar.zst
bun-f9b966c13f5ed3d870c54b69cb59a5adc12060b7.zip
Bun Terminal
Diffstat (limited to 'packages/bun-debug-adapter-protocol/src/debugger/adapter.ts')
-rw-r--r--packages/bun-debug-adapter-protocol/src/debugger/adapter.ts27
1 files changed, 15 insertions, 12 deletions
diff --git a/packages/bun-debug-adapter-protocol/src/debugger/adapter.ts b/packages/bun-debug-adapter-protocol/src/debugger/adapter.ts
index cd1b656a7..33555dbb0 100644
--- a/packages/bun-debug-adapter-protocol/src/debugger/adapter.ts
+++ b/packages/bun-debug-adapter-protocol/src/debugger/adapter.ts
@@ -109,7 +109,6 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener {
#initialized?: InitializeRequest;
#launched?: LaunchRequest;
#connected?: boolean;
- #terminated?: boolean;
constructor({ url, send, stdout, stderr, ...options }: DebugAdapterOptions) {
this.#url = new URL(url);
@@ -129,6 +128,10 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener {
this.#variables = [{ name: "", value: "", type: undefined, variablesReference: 0 }];
}
+ get inspector(): UnixWebSocketInspector {
+ return this.#inspector;
+ }
+
async accept(message: DAP.Request | DAP.Response | DAP.Event): Promise<void> {
const { type } = message;
@@ -414,7 +417,18 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener {
async #attach(request: AttachRequest): Promise<void> {
const { url } = request;
+ if (this.#url.href === url) {
+ this.#emit("output", {
+ category: "debug console",
+ output: "Debugger attached.\n",
+ });
+
+ this.configurationDone();
+ return;
+ }
+
if (await this.#start(url)) {
+ this.configurationDone();
return;
}
@@ -422,7 +436,6 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener {
}
terminate(): void {
- this.#terminated = true;
this.#process?.kill();
}
@@ -855,14 +868,6 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener {
output: "Debugger detached.\n",
});
- if (error && !this.#terminated) {
- const { message } = error;
- this.#emit("output", {
- category: "stderr",
- output: `${message}\n`,
- });
- }
-
this.#emit("terminated");
this.#reset();
}
@@ -1426,7 +1431,6 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener {
}
close(): void {
- this.#terminated = true;
this.#process?.kill();
this.#inspector.close();
this.#reset();
@@ -1444,7 +1448,6 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener {
this.#launched = undefined;
this.#initialized = undefined;
this.#connected = undefined;
- this.#terminated = undefined;
}
}