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

Debug Attach: fix process picker error #1412

Merged
merged 1 commit into from
Jul 25, 2024
Merged
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
41 changes: 38 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,42 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
}),
vscode.commands.registerCommand("vscode-objectscript.pickProcess", async (config) => {
const system = config.system;
const api = new AtelierAPI(vscode.window.activeTextEditor?.document.uri);
let connectionUri = vscode.window.activeTextEditor?.document.uri;
if (connectionUri) {
// Ignore active editor if its document is outside the workspace (e.g. user settings.json)
connectionUri = vscode.workspace.getWorkspaceFolder(connectionUri)?.uri;
}
if (!connectionUri) {
// May need to ask the user
const workspaceFolders = vscode.workspace.workspaceFolders || [];
if (workspaceFolders.length == 0) {
vscode.window.showErrorMessage(`Attaching to a server process requires a workspace to be open.`, {
modal: true,
});
return;
}
if (workspaceFolders.length == 1) {
connectionUri = workspaceFolders[0].uri;
} else {
// Pick from the workspace folders
connectionUri = (
await vscode.window.showWorkspaceFolderPick({
ignoreFocusOut: true,
placeHolder: "Pick the workspace folder to get server connection information from",
})
)?.uri;
}
}
if (!connectionUri) {
return;
}
const api = new AtelierAPI(connectionUri);
if (!api.active) {
vscode.window.showErrorMessage(`No active server connection.`, {
modal: true,
});
return;
}

const list = await api.getJobs(system).then(async (jobData) => {
// NOTE: We do not know if the current user has permissions to other namespaces
Expand Down Expand Up @@ -969,14 +1004,14 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
});
});
if (!list.length) {
vscode.window.showInformationMessage(`No attachable processes are running in ${api.ns}.`, {
vscode.window.showInformationMessage(`No attachable processes are running in ${api.ns} on '${api.serverId}'.`, {
modal: true,
});
return;
}
return vscode.window
.showQuickPick<vscode.QuickPickItem>(list, {
placeHolder: "Pick the process to attach to",
placeHolder: `Pick the process to attach to in ${api.ns} on '${api.serverId}'`,
matchOnDescription: true,
})
.then((value) => {
Expand Down