-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Introduce DebugSession#workspaceFolder #11090
Introduce DebugSession#workspaceFolder #11090
Conversation
61a3a79
to
d476ea3
Compare
@@ -214,7 +214,7 @@ export class DebugSessionManager { | |||
} | |||
} | |||
|
|||
const sessionId = await this.debug.createDebugSession(resolved.configuration); | |||
const sessionId = await this.debug.createDebugSession(resolved.configuration, options.workspaceFolderUri); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not appear that the implementation of the createDebugSession
method on the DebugServiceImpl
has been updated to handle the workspaceFolderUri
. Is that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. No, this was an oversight, since this value is not needed there.
In the plain Theia API the ws folder is taken from the DebugSessionOptions
and we only need it for vs code compatibility.
I've added the parameter as _workspaceFolderUri?
c50970f
to
08baedf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fault, but in my suggested snippet, I omitted a space between this.configuration.name
and (${suffixes.join(' - ')})
. Apart from that minor UI issue, this looks good to me, so if you fix that, I'll approve.
const showWSFolderInLabel = this.workspaceService.isMultiRootWorkspaceOpened && this.options.workspaceFolderUri; | ||
if (showWSFolderInLabel) { | ||
const wsFolder = this.labelProvider.getName(new URI(this.options.workspaceFolderUri)); | ||
if (InternalDebugSessionOptions.is(this.options) && this.options.id) { | ||
return this.configuration.name + ' (' + (this.options.id + 1) + ' - ' + wsFolder + ')'; | ||
} | ||
return this.configuration.name + ' (' + wsFolder + ')'; | ||
} else { | ||
if (InternalDebugSessionOptions.is(this.options) && this.options.id) { | ||
return this.configuration.name + ' (' + (this.options.id + 1) + ')'; | ||
} | ||
return this.configuration.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const showWSFolderInLabel = this.workspaceService.isMultiRootWorkspaceOpened && this.options.workspaceFolderUri; | |
if (showWSFolderInLabel) { | |
const wsFolder = this.labelProvider.getName(new URI(this.options.workspaceFolderUri)); | |
if (InternalDebugSessionOptions.is(this.options) && this.options.id) { | |
return this.configuration.name + ' (' + (this.options.id + 1) + ' - ' + wsFolder + ')'; | |
} | |
return this.configuration.name + ' (' + wsFolder + ')'; | |
} else { | |
if (InternalDebugSessionOptions.is(this.options) && this.options.id) { | |
return this.configuration.name + ' (' + (this.options.id + 1) + ')'; | |
} | |
return this.configuration.name; | |
const suffixes = []; | |
if (InternalDebugSessionOptions.is(this.options) && this.options.id !== undefined) { | |
suffixes.push(String(this.options.id + 1)); | |
} | |
if (this.workspaceService.isMultiRootWorkspaceOpened && this.options.workspaceFolderUri) { | |
suffixes.push(this.labelProvider.getName(new URI(this.options.workspaceFolderUri))); | |
} | |
return suffixes.length === 0 ? this.configuration.name : this.configuration.name + `(${suffixes.join(' - ')})`; |
The WorkspaceService
fields about multi-root workspaces are a bit counterintuitive. The code above will show the workspace root if the workspace is defined in a file, even if there is only a single root. I think that's fine behavior, but if we want to display the root only when there are actually multiple roots in the workspace, then this.workspaceService.tryGetRoots().length > 1
is the most informative check.
* add to model and adjust session creation Contributed on behalf of STMicroelectronics Signed-off-by: Johannes Faltermeier <[email protected]>
* Adapt DebugSessions Tree Model Contributed on behalf of STMicroelectronics Signed-off-by: Johannes Faltermeier <[email protected]>
also: * add missing parameter to DebugServiceImpl * remove unenecessary addition from Theia DebugConfiguration Co-authored-by: colin-grant-work <[email protected]> Contributed on behalf of STMicroelectronics
08baedf
to
f3f4552
Compare
I've added the space between configuration name and the joined suffixes and rebased on current master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. 👍
What it does
Fixes #10023
workspaceFolderUri
to theDebugSession
APIworkspaceFolderUri
DebugSessionManager
was already honoring the workspace folder as far as I could see (-> e.g. when executing pre launch tasks:theia/packages/debug/src/browser/debug-session-manager.ts
Line 211 in 7f5047f
VS-Code UI (esm-i was the set workspace-folder. This is not shown in the Top, because this is a launch without a set ws folder):
Theia UI (workspace folder was called java):
Contributed on behalf of STMicroelectronics
Signed-off-by: Johannes Faltermeier [email protected]
How to test
I've created a small VSCode extension that tracks the creation of debug sessions and logs the workspace folder of a session:
https://github.com/jfaltermeier/vscode-debug-playground
https://github.com/jfaltermeier/vscode-debug-playground/blob/main/src/extension.ts
You may get this test extension from https://github.com/jfaltermeier/vscode-debug-playground/releases/tag/0.0.1
This should create a log message similar to this one:
Without the changes, the worspaceFolder was undefined all the time
Review checklist
Reminder for reviewers