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
Show file tree
Hide file tree
Changes from 6 commits
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
6 changes: 6 additions & 0 deletions package.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@
"leetcode-cn"
],
"description": "Endpoint of the user account."
},
"leetcode.outputPath": {
"type": "string",
"default": "",
"scope": "application",
"description": "Specifies the relative path to save the problem files."
}
}
}
Expand Down
30 changes: 29 additions & 1 deletion src/commands/show.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function searchProblem(): Promise<void> {

async function showProblemInternal(id: string): Promise<void> {
try {
const listProblems: IProblem[] = await list.listProblems();
const leetCodeConfig: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("leetcode");
let defaultLanguage: string | undefined = leetCodeConfig.get<string>("defaultLanguage");
if (defaultLanguage && languages.indexOf(defaultLanguage) < 0) {
Expand All @@ -49,7 +50,34 @@ async function showProblemInternal(id: string): Promise<void> {
return;
}

const outDir: string = await selectWorkspaceFolder();
let outDir: string = await selectWorkspaceFolder();
const outputPath: string = leetCodeConfig.get<string>("outputPath") || "";
const problem: IProblem | undefined = listProblems.find((item: IProblem) => item.id === id);
switch (outputPath) {
case "": {
break;
}
case "${tag}": {
if (problem) {
outDir = `${outDir}/${problem.tags[0]}`;
}
break;
}
case "${language}": {
outDir = `${outDir}/${language}`;
break;
}
case "${difficulty}": {
if (problem) {
outDir = `${outDir}/${problem.difficulty}`;
}
break;
}
default: {
outDir = `${outDir}/${outputPath}`;
break;
}
}
await fse.ensureDir(outDir);
const result: string = await leetCodeExecutor.showProblem(id, language, outDir);
const reg: RegExp = /\* Source Code:\s*(.*)/;
Expand Down

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