Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make --inspect-wait default when debugging #775

Merged
merged 1 commit into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions client/src/debug_config_provider.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.

import type { Settings } from "./types";
import type { DenoExtensionContext } from "./types";
import { getDenoCommandName } from "./util";
import * as semver from "semver";
import * as vscode from "vscode";

export class DenoDebugConfigurationProvider
implements vscode.DebugConfigurationProvider {
#getSettings: () => Settings;
#extensionContext: DenoExtensionContext;

#getEnv() {
const cache = this.#getSettings().cache;
const cache = this.#extensionContext.clientOptions.initializationOptions().cache;
return cache ? { "DENO_DIR": cache } : undefined;
}

#getAdditionalRuntimeArgs() {
const args: string[] = [];
const settings = this.#getSettings();
const settings = this.#extensionContext.clientOptions.initializationOptions();
if (settings.unstable) {
args.push("--unstable");
}
Expand All @@ -30,8 +31,18 @@ export class DenoDebugConfigurationProvider
return args;
}

constructor(getSettings: () => Settings) {
this.#getSettings = getSettings;
#getInspectArg() {
const version = this.#extensionContext.serverInfo?.version;

if (version && semver.valid(version) && semver.satisfies(version, ">=1.29.0")) {
return "--inspect-wait"
} else {
return "--inspect";
Leokuma marked this conversation as resolved.
Show resolved Hide resolved
}
}

constructor(extensionContext: DenoExtensionContext) {
this.#extensionContext = extensionContext;
}

async provideDebugConfigurations(): Promise<vscode.DebugConfiguration[]> {
Expand All @@ -47,7 +58,7 @@ export class DenoDebugConfigurationProvider
runtimeArgs: [
"run",
...this.#getAdditionalRuntimeArgs(),
"--inspect",
this.#getInspectArg(),
"--allow-all",
],
attachSimplePort: 9229,
Expand Down Expand Up @@ -80,7 +91,7 @@ export class DenoDebugConfigurationProvider
runtimeArgs: [
"run",
...this.#getAdditionalRuntimeArgs(),
"--inspect",
this.#getInspectArg(),
"--allow-all",
],
attachSimplePort: 9229,
Expand Down
2 changes: 1 addition & 1 deletion client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export async function activate(
context.subscriptions.push(
vscode.debug.registerDebugConfigurationProvider(
"deno",
new DenoDebugConfigurationProvider(getWorkspaceSettings),
new DenoDebugConfigurationProvider(extensionContext),
),
);

Expand Down