Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions 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": "Determine whether to generate problem description as comment in code file."
},
"leetcode.showSetDefaultLanguageHint": {
"type": "boolean",
"default": true,
Expand Down
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 codeType: 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, codeType, "-l", language]);
await fse.writeFile(filePath, codeTemplate);
}

Expand Down