Skip to content
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

Add showCommentDescription config #289

Merged
merged 3 commits into from
Apr 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 6 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@
"scope": "application",
"description": "Default language for solving the problems."
},
"leetcode.showCommentDescription": {
"type": "boolean",
"default": false,
"scope": "application",
"description": "Include problem description in comments."
},
"leetcode.showSetDefaultLanguageHint": {
"type": "boolean",
"default": true,
Expand Down Expand Up @@ -344,6 +350,6 @@
"markdown-it": "^8.4.2",
"require-from-string": "^2.0.2",
"unescape-js": "^1.1.1",
"vsc-leetcode-cli": "2.6.4"
"vsc-leetcode-cli": "2.6.5"
}
}
2 changes: 1 addition & 1 deletion src/commands/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async function showProblemInternal(node: IProblem): Promise<void> {
outDir = path.join(outDir, relativePath);
await fse.ensureDir(outDir);

const originFilePath: string = await leetCodeExecutor.showProblem(node, language, outDir);
const originFilePath: string = await leetCodeExecutor.showProblem(node, language, outDir, leetCodeConfig.get<boolean>("showCommentDescription"));
const filePath: string = wsl.useWsl() ? await wsl.toWinPath(originFilePath) : originFilePath;
await Promise.all([
vscode.window.showTextDocument(vscode.Uri.file(filePath), { preview: false, viewColumn: vscode.ViewColumn.One }),
Expand Down
5 changes: 3 additions & 2 deletions src/leetCodeExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ class LeetCodeExecutor implements Disposable {
);
}

public async showProblem(problemNode: IProblem, language: string, outDir: string): Promise<string> {
public async showProblem(problemNode: IProblem, language: string, outDir: string, detailed: boolean = false): Promise<string> {
const fileName: string = genFileName(problemNode, language);
const filePath: string = path.join(outDir, fileName);
const templateType: string = detailed ? "-cx" : "-c";

if (!await fse.pathExists(filePath)) {
const codeTemplate: string = await this.executeCommandWithProgressEx("Fetching problem data...", this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "show", problemNode.id, "-cx", "-l", language]);
const codeTemplate: string = await this.executeCommandWithProgressEx("Fetching problem data...", this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "show", problemNode.id, templateType, "-l", language]);
await fse.writeFile(filePath, codeTemplate);
}

Expand Down