Skip to content

Commit

Permalink
change the place of the lock decorator (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdneo committed Mar 13, 2018
1 parent a44d3db commit f2b1a75
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/commands/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,22 @@ async function showProblemInternal(channel: vscode.OutputChannel, id: string): P
async function parseProblemsToPicks(p: Promise<list.IProblem[]>): Promise<Array<IQuickItemEx<string>>> {
return new Promise(async (resolve: (res: Array<IQuickItemEx<string>>) => void): Promise<void> => {
const picks: Array<IQuickItemEx<string>> = (await p).map((problem: list.IProblem) => Object.assign({}, {
label: `${parseProblemDecorator(problem.state)}${problem.id}.${problem.name}`,
label: `${parseProblemDecorator(problem.state, problem.locked)}${problem.id}.${problem.name}`,
description: "",
detail: `${parseLockDecorator(problem.locked)}AC rate: ${problem.passRate}, Difficulty: ${problem.difficulty}`,
detail: `AC rate: ${problem.passRate}, Difficulty: ${problem.difficulty}`,
value: problem.id,
}));
resolve(picks);
});
}

function parseProblemDecorator(state: ProblemState): string {
function parseProblemDecorator(state: ProblemState, locked: boolean): string {
switch (state) {
case ProblemState.AC:
return "$(check) ";
case ProblemState.NotAC:
return "$(x) ";
default:
return "";
return locked ? "$(lock) " : "";
}
}

function parseLockDecorator(locked: boolean): string {
return locked ? "$(lock) " : "";
}

0 comments on commit f2b1a75

Please sign in to comment.