Skip to content

Commit 11892ff

Browse files
committed
fix: store original handle of debug adapter config
When frontend and main VS Code extensions load together, Theia creates two extension host instances to manage different kinds of extensions. Each will register the extensions' contributed debug adapter configuration providers with incremented handles. In cases of handle collisions during the registration of debug configurations, Theia adjusts the handle of incoming providers. However, this adjustment causes issues as the extension host no longer associates the new handle with the original ID. For instance, if the main VSIX contributes two debuggers assigned handles `0` and `1`, and the web VSIX contributes a debugger with a colliding handle `0`, Theia changes the web provider's handle to `2`. Subsequently, when starting a debug session, the main extension attempts to resolve handle `2`, but the frontend extension host only recognizes the initial configuration. This commit addresses the issue by storing the original handle of the debug adapter configuration. During handle ID lookups, it will reference the originally assigned handle instead of the adjusted one, ensuring proper resolution and functionality across both extension host instances. Ref: eclipse-theia#13196
1 parent afde78f commit 11892ff

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/plugin-ext/src/main/browser/debug/plugin-debug-configuration-provider.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ import {
2323
import { DebugConfiguration } from '@theia/debug/lib/common/debug-configuration';
2424

2525
export class PluginDebugConfigurationProvider implements DebugConfigurationProvider {
26+
/**
27+
* After https://github.com/eclipse-theia/theia/pull/13196, the debug config handles might change.
28+
* Store the original handle to be able to call the extension host when getting by handle.
29+
*/
30+
protected readonly originalHandle: number;
2631
public handle: number;
2732
public type: string;
2833
public triggerKind: DebugConfigurationProviderTriggerKind;
@@ -41,23 +46,24 @@ export class PluginDebugConfigurationProvider implements DebugConfigurationProvi
4146
protected readonly debugExt: DebugExt
4247
) {
4348
this.handle = description.handle;
49+
this.originalHandle = this.handle;
4450
this.type = description.type;
4551
this.triggerKind = description.trigger;
4652

4753
if (description.provideDebugConfiguration) {
48-
this.provideDebugConfigurations = async (folder: string | undefined) => this.debugExt.$provideDebugConfigurationsByHandle(this.handle, folder);
54+
this.provideDebugConfigurations = async (folder: string | undefined) => this.debugExt.$provideDebugConfigurationsByHandle(this.originalHandle, folder);
4955
}
5056

5157
if (description.resolveDebugConfigurations) {
5258
this.resolveDebugConfiguration =
5359
async (folder: string | undefined, debugConfiguration: DebugConfiguration) =>
54-
this.debugExt.$resolveDebugConfigurationByHandle(this.handle, folder, debugConfiguration);
60+
this.debugExt.$resolveDebugConfigurationByHandle(this.originalHandle, folder, debugConfiguration);
5561
}
5662

5763
if (description.resolveDebugConfigurationWithSubstitutedVariables) {
5864
this.resolveDebugConfigurationWithSubstitutedVariables =
5965
async (folder: string | undefined, debugConfiguration: DebugConfiguration) =>
60-
this.debugExt.$resolveDebugConfigurationWithSubstitutedVariablesByHandle(this.handle, folder, debugConfiguration);
66+
this.debugExt.$resolveDebugConfigurationWithSubstitutedVariablesByHandle(this.originalHandle, folder, debugConfiguration);
6167
}
6268
}
6369
}

0 commit comments

Comments
 (0)