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

Commit 0109197

Browse files
Vigilansjdneo
authored andcommitted
feat: Add showCommentDescription config (#289)
1 parent 9dbe4fd commit 0109197

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

‎package-lock.json

Lines changed: 6 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@
262262
"scope": "application",
263263
"description": "Default language for solving the problems."
264264
},
265+
"leetcode.showCommentDescription": {
266+
"type": "boolean",
267+
"default": false,
268+
"scope": "application",
269+
"description": "Include problem description in comments."
270+
},
265271
"leetcode.showSetDefaultLanguageHint": {
266272
"type": "boolean",
267273
"default": true,
@@ -344,6 +350,6 @@
344350
"markdown-it": "^8.4.2",
345351
"require-from-string": "^2.0.2",
346352
"unescape-js": "^1.1.1",
347-
"vsc-leetcode-cli": "2.6.4"
353+
"vsc-leetcode-cli": "2.6.5"
348354
}
349355
}

‎src/commands/show.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ async function showProblemInternal(node: IProblem): Promise<void> {
115115
outDir = path.join(outDir, relativePath);
116116
await fse.ensureDir(outDir);
117117

118-
const originFilePath: string = await leetCodeExecutor.showProblem(node, language, outDir);
118+
const originFilePath: string = await leetCodeExecutor.showProblem(node, language, outDir,leetCodeConfig.get<boolean>("showCommentDescription"));
119119
const filePath: string = wsl.useWsl() ? await wsl.toWinPath(originFilePath) : originFilePath;
120120
await Promise.all([
121121
vscode.window.showTextDocument(vscode.Uri.file(filePath), { preview: false, viewColumn: vscode.ViewColumn.One }),

‎src/leetCodeExecutor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,13 @@ class LeetCodeExecutor implements Disposable {
9494
);
9595
}
9696

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

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

0 commit comments

Comments
(0)

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