Skip to content
Open
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
Prev Previous commit
fix: corner case
  • Loading branch information
jtchen2k committed Oct 9, 2021
commit ab6bce87878a72dd858cacc61bed2ec52c801b7a
13 changes: 9 additions & 4 deletions src/commands/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,24 @@ export async function problemOfToday(): Promise<void> {
return;
}
try {
const nodes: LeetCodeNode[] = await explorerNodeManager.getAllNodes()
const nodes: LeetCodeNode[] = explorerNodeManager.getAllNodes()
const problemOfTodayStr: string = await leetCodeExecutor.problemOfToday();
const lines: string[] = problemOfTodayStr.split("\n");
const reg: RegExp = /^\[(.+)\]\s.*/
const match: RegExpMatchArray | null = lines[0].match(reg);
if (match != null) {
const id = match[1]
const problemOfToday: IProblem = nodes.filter(one => one.id === id)[0];
await showProblemInternal(problemOfToday);
const problemOfToday: IProblem[] = nodes.filter(one => one.id === id);
if (problemOfToday.length != 1) {
await promptForOpenOutputChannel("Fail to load problem of today. You may need to refresh the problem list.", DialogType.error);
}
else {
await showProblemInternal(problemOfToday[0]);
}
}
}
catch {
await promptForOpenOutputChannel("Fail to load problem of today. You may need to refresh the problem list. Open the output channel for details.", DialogType.error);
await promptForOpenOutputChannel("Fail to load problem of today. Open the output channel for details.", DialogType.error);
}
}

Expand Down