Files
arduino-ide/arduino-ide-extension/src/browser/theia/debug/debug-session-manager.ts
Akos Kitta 73b6dc4774 feat: use new debug -I -P CLI output
- Can pick a programmer if missing,
 - Can auto-select a programmer on app start,
 - Can edit the `launch.json`,
 - Adjust board discovery to new gRPC API. From now on, it's a client
 read stream, not a duplex.
 - Allow `.cxx` and `.cc` file extensions. (Closes #2265)
 - Drop `debuggingSupported` from `BoardDetails`.
 - Dedicated service endpoint for checking the debugger.

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
2023-12-13 17:32:07 +01:00

40 lines
1.5 KiB
TypeScript

import { inject, injectable } from '@theia/core/shared/inversify';
import { DebugSession } from '@theia/debug/lib/browser/debug-session';
import { DebugSessionManager as TheiaDebugSessionManager } from '@theia/debug/lib/browser/debug-session-manager';
import { DebugConfigurationSessionOptions } from '@theia/debug/lib/browser/debug-session-options';
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
import deepEqual from 'fast-deep-equal';
@injectable()
export class DebugSessionManager extends TheiaDebugSessionManager {
@inject(WorkspaceService)
private readonly workspaceService: WorkspaceService;
protected override doStart(
sessionId: string,
options: DebugConfigurationSessionOptions
): Promise<DebugSession> {
this.syncCurrentOptions(options);
return super.doStart(sessionId, options);
}
/**
* If the debug config manager knows about the currently started options, and it's not the currently selected one, select it.
*/
private syncCurrentOptions(options: DebugConfigurationSessionOptions): void {
const knownConfigOptions = this.debugConfigurationManager.find(
options.configuration,
options.workspaceFolderUri ??
this.workspaceService
.tryGetRoots()
.map((stat) => stat.resource.toString())[0]
);
if (
knownConfigOptions &&
!deepEqual(knownConfigOptions, this.debugConfigurationManager.current)
) {
this.debugConfigurationManager.current = knownConfigOptions;
}
}
}