diff --git a/src/debugger/debugger.ts b/src/debugger/debugger.ts index 1d6904a..85f1f07 100644 --- a/src/debugger/debugger.ts +++ b/src/debugger/debugger.ts @@ -109,7 +109,7 @@ export class GodotDebugger implements DebugAdapterDescriptorFactory, DebugConfig log.info(`Project version identified as ${projectVersion}`); if (projectVersion.startsWith("4")) { - this.session = new Godot4DebugSession(); + this.session = new Godot4DebugSession(projectVersion); } else { this.session = new Godot3DebugSession(); } diff --git a/src/debugger/godot4/debug_session.ts b/src/debugger/godot4/debug_session.ts index b1b7f94..b215c80 100644 --- a/src/debugger/godot4/debug_session.ts +++ b/src/debugger/godot4/debug_session.ts @@ -29,11 +29,13 @@ export class GodotDebugSession extends LoggingDebugSession { public variables_manager: VariablesManager; - public constructor() { + public constructor(projectVersion : string) { super(); this.setDebuggerLinesStartAt1(false); this.setDebuggerColumnsStartAt1(false); + + this.controller.setProjectVersion(projectVersion); } public dispose() { @@ -91,6 +93,7 @@ export class GodotDebugSession extends LoggingDebugSession { this.mode = "attach"; + this.debug_data.projectPath = args.project; this.exception = false; await this.controller.attach(args); diff --git a/src/debugger/godot4/server_controller.ts b/src/debugger/godot4/server_controller.ts index b131377..e9f1ec4 100644 --- a/src/debugger/godot4/server_controller.ts +++ b/src/debugger/godot4/server_controller.ts @@ -75,10 +75,19 @@ export class ServerController { private steppingOut = false; private didFirstOutput = false; private partialStackVars: GodotPartialStackVars; - private connectedVersion = ""; + private projectVersionMajor: number; + private projectVersionMinor : number; + private projectVersionPoint : number; public constructor(public session: GodotDebugSession) {} + public setProjectVersion(projectVersion: string) { + const versionParts = projectVersion.split('.').map(Number); + this.projectVersionMajor = versionParts[0] || 0; + this.projectVersionMinor = versionParts[1] || 0; + this.projectVersionPoint = versionParts[2] || 0; + } + public break() { this.send_command("break"); } @@ -204,7 +213,7 @@ export class ServerController { } } - this.connectedVersion = result.version; + this.setProjectVersion(result.version); let command = `"${godotPath}" --path "${args.project}"`; const address = args.address.replace("tcp://", ""); @@ -381,7 +390,7 @@ export class ServerController { const command = new Command(); let i = 0; command.command = dataset[i++]; - if (this.connectedVersion[2] >= "2") { + if (this.projectVersionMinor >= 2) { command.threadId = dataset[i++]; } command.parameters = dataset[i++]; @@ -691,7 +700,7 @@ export class ServerController { private send_command(command: string, parameters?: any[]) { const commandArray: any[] = [command]; - if (this.connectedVersion[2] >= "2") { + if (this.projectVersionMinor >= 2) { commandArray.push(this.threadId); } commandArray.push(parameters ?? []);