Skip to content

fix session switch bug #13

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

Merged
merged 2 commits into from
Feb 26, 2018
Merged
Changes from 1 commit
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
Next Next commit
fix session switch bug
  • Loading branch information
jdneo committed Feb 26, 2018
commit 772304ac624c9299e8b4f74048cb81f5f1085bf8
12 changes: 9 additions & 3 deletions src/commands/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function getSessionList(channel: vscode.OutputChannel): Promise<ISe
}

export async function selectSession(channel: vscode.OutputChannel): Promise<void> {
const choice: IQuickItemEx<string> | undefined = await vscode.window.showQuickPick(parseSessionsToPicks(getSessionList(channel)));
const choice: IQuickItemEx<string> | undefined = await vscode.window.showQuickPick(parseSessionsToPicks(channel));
if (!choice || choice.description === "Active") {
return;
}
Expand All @@ -49,9 +49,15 @@ export async function selectSession(channel: vscode.OutputChannel): Promise<void
}
}

async function parseSessionsToPicks(p: Promise<ISession[]>): Promise<Array<IQuickItemEx<string>>> {
async function parseSessionsToPicks(channel: vscode.OutputChannel): Promise<Array<IQuickItemEx<string>>> {
return new Promise(async (resolve: (res: Array<IQuickItemEx<string>>) => void): Promise<void> => {
const picks: Array<IQuickItemEx<string>> = (await p).map((s: ISession) => Object.assign({}, {
let sessions: ISession[];
try {
sessions = await getSessionList(channel);
} catch (error) {
return await promptForOpenOutputChannel("Failed to switch session. Please open the output channel for details", DialogType.error, channel);
}
const picks: Array<IQuickItemEx<string>> = sessions.map((s: ISession) => Object.assign({}, {
label: `${s.active ? "$(check) " : ""}${s.name}`,
description: s.active ? "Active" : "",
detail: `AC Questions: ${s.acQuestions}, AC Submits: ${s.acSubmits}`,
Expand Down