Skip to content

Commit 2a11e1b

Browse files
committed
fix session bug
1 parent 9b7eb3a commit 2a11e1b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/commands/list.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ export async function listProblems(): Promise<IProblem[]> {
2323
const problems: IProblem[] = [];
2424
const lines: string[] = result.split("\n");
2525
const reg: RegExp = /(.?)\s*\[\s*(\d*)\]\s*(.*)\s*(Easy|Medium|Hard)\s*\((\s*\d+\.\d+ %)\)/;
26-
for (const line of lines.map((l: string) => l.trim()).filter(Boolean)) {
26+
for (const line of lines) {
2727
const match: RegExpMatchArray | null = line.match(reg);
2828
if (match && match.length === 6) {
2929
problems.push({
30-
solved: !!match[1],
30+
solved: !!(match[1].trim()),
3131
id: match[2].trim(),
3232
name: match[3].trim(),
3333
difficulty: match[4].trim(),

src/commands/session.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ export async function getSessionList(): Promise<ISession[]> {
1616
const lines: string[] = result.split("\n");
1717
const sessions: ISession[] = [];
1818
const reg: RegExp = /(.?)\s*(\d+)\s+(.*)\s+(\d+ \(\s*\d+\.\d+ %\))\s+(\d+ \(\s*\d+\.\d+ %\))/;
19-
for (const line of lines.map((l: string) => l.trim()).filter(Boolean)) {
19+
for (const line of lines) {
2020
const match: RegExpMatchArray | null = line.match(reg);
2121
if (match && match.length === 6) {
2222
sessions.push({
23-
active: !!match[1],
23+
active: !!(match[1].trim()),
2424
id: match[2].trim(),
2525
name: match[3].trim(),
2626
acQuestions: match[4].trim(),
@@ -43,6 +43,7 @@ export async function selectSession(): Promise<void> {
4343
try {
4444
await cp.executeCommand("node", [leetCodeBinaryPath, "session", "-e", choice.value]);
4545
vscode.window.showInformationMessage(`Successfully switched to session '${choice.label}'.`);
46+
await vscode.commands.executeCommand("leetcode.refreshExplorer");
4647
} catch (error) {
4748
await promptForOpenOutputChannel("Failed to switch session. Please open the output channel for details", DialogType.error);
4849
}
@@ -59,6 +60,7 @@ async function parseSessionsToPicks(p: Promise<ISession[]>): Promise<Array<IQuic
5960
picks.push({
6061
label: "$(plus) Create a new session",
6162
description: "",
63+
detail: "Click this item to create a new session",
6264
value: ":createNewSession",
6365
});
6466
resolve(picks);
@@ -75,6 +77,7 @@ export async function createSession(): Promise<void> {
7577
}
7678
try {
7779
await cp.executeCommand("node", [leetCodeBinaryPath, "session", "-c", session]);
80+
vscode.window.showInformationMessage("New session created, you can switch to it by clicking the status bar.");
7881
} catch (error) {
7982
await promptForOpenOutputChannel("Failed to create session. Please open the output channel for details", DialogType.error);
8083
}

0 commit comments

Comments
 (0)