Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add outputPath Config #123

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
jdneo merged 15 commits into LeetCode-OpenSource:master from ringcrl:master
Feb 16, 2019
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
Next Next commit
feat: add tag selector
  • Loading branch information
chengruilin committed Feb 16, 2019
commit f6352cdc13c1abd934452e726969f08d717d8851
34 changes: 22 additions & 12 deletions src/commands/show.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function searchProblem(): Promise<void> {
return;
}
const problems: IProblem[] = await list.listProblems();
const choice: IQuickItemEx<string> | undefined = await vscode.window.showQuickPick(
const choice: IQuickItemEx<IProblem> | undefined = await vscode.window.showQuickPick(
parseProblemsToPicks(problems),
{
matchOnDetail: true,
Expand All @@ -36,7 +36,7 @@ export async function searchProblem(): Promise<void> {
if (!choice) {
return;
}
await showProblemInternal(problems.find((problem: IProblem) => problem.id === choice.value) as IProblem);
await showProblemInternal(choice.value);
}

async function showProblemInternal(node: IProblem): Promise<void> {
Expand All @@ -57,12 +57,22 @@ async function showProblemInternal(node: IProblem): Promise<void> {
if (outputPath) {
switch (outputPath[1].toLowerCase()) {
case "tag":
const closestTag: string = node.tags.reduce((prev: string, curr: string) => {
return curr.length > prev.length ?
curr :
prev;
}, "");
outDir = path.join(outDir, closestTag);
let tag: string | undefined;
if (node.tags.length === 1) {
tag = node.tags[0];
} else {
tag = await vscode.window.showQuickPick(
node.tags,
{
matchOnDetail: true,
placeHolder: "Select one tag",
},
);
}
if (!tag) {
return;
}
outDir = path.join(outDir, tag);
break;
case "language":
outDir = path.join(outDir, language);
Expand Down Expand Up @@ -108,13 +118,13 @@ async function showProblemInternal(node: IProblem): Promise<void> {
}
}

async function parseProblemsToPicks(p: IProblem[]): Promise<Array<IQuickItemEx<string>>> {
return new Promise(async (resolve: (res: Array<IQuickItemEx<string>>) => void): Promise<void> => {
const picks: Array<IQuickItemEx<string>> = p.map((problem: IProblem) => Object.assign({}, {
async function parseProblemsToPicks(p: IProblem[]): Promise<Array<IQuickItemEx<IProblem>>> {
return new Promise(async (resolve: (res: Array<IQuickItemEx<IProblem>>) => void): Promise<void> => {
const picks: Array<IQuickItemEx<IProblem>> = p.map((problem: IProblem) => Object.assign({}, {
label: `${parseProblemDecorator(problem.state, problem.locked)}${problem.id}.${problem.name}`,
description: "",
detail: `AC rate: ${problem.passRate}, Difficulty: ${problem.difficulty}`,
value: problem.id,
value: problem,
}));
resolve(picks);
});
Expand Down

AltStyle によって変換されたページ (->オリジナル) /