diff --git a/package-lock.json b/package-lock.json index 91adab65..a175bbad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -67,8 +67,7 @@ "acorn": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-2.7.0.tgz", - "integrity": "sha1-q259nYhqrKiwhbwzEreaGYQz8Oc=", - "optional": true + "integrity": "sha1-q259nYhqrKiwhbwzEreaGYQz8Oc=" }, "acorn-globals": { "version": "1.0.9", @@ -375,8 +374,7 @@ "cssom": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.6.tgz", - "integrity": "sha512-DtUeseGk9/GBW0hl0vVPpU22iHL6YB5BUX7ml1hB+GMpo0NX5G4voX3kdWiMSEguFtcW3Vh3djqNF4aIe6ne0A==", - "optional": true + "integrity": "sha512-DtUeseGk9/GBW0hl0vVPpU22iHL6YB5BUX7ml1hB+GMpo0NX5G4voX3kdWiMSEguFtcW3Vh3djqNF4aIe6ne0A==" }, "cssstyle": { "version": "0.2.37", @@ -1333,8 +1331,7 @@ "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "optional": true + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" }, "prompt": { "version": "1.0.0", @@ -1698,7 +1695,6 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "optional": true, "requires": { "prelude-ls": "~1.1.2" } @@ -1786,9 +1782,9 @@ } }, "vsc-leetcode-cli": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/vsc-leetcode-cli/-/vsc-leetcode-cli-2.6.4.tgz", - "integrity": "sha512-vHcy2WQmQlcm2jB2m5Z+2RfuW0/4S+WjOhXE7twn2lvMgb9jqq3h+MYVHr1ijxraRwiCb5sGknz0T17zkob3gA==", + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/vsc-leetcode-cli/-/vsc-leetcode-cli-2.6.5.tgz", + "integrity": "sha512-Veb7FpiijEt6G2BEJ+90tgqXxkagEme/jSoidL26GClgVxpki3VYv9h8Zd9X6xY2VEaduefhoVCwqZ6SQ2P7Kg==", "requires": { "ansi-styles": "3.2.1", "cheerio": "0.20.0", diff --git a/package.json b/package.json index 7f8d6368..ce3476a8 100644 --- a/package.json +++ b/package.json @@ -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, @@ -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" } } diff --git a/src/commands/show.ts b/src/commands/show.ts index 1f7b7e52..8447e8da 100644 --- a/src/commands/show.ts +++ b/src/commands/show.ts @@ -115,7 +115,7 @@ async function showProblemInternal(node: IProblem): Promise { 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("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 }), diff --git a/src/leetCodeExecutor.ts b/src/leetCodeExecutor.ts index a142fbf2..27b896c1 100644 --- a/src/leetCodeExecutor.ts +++ b/src/leetCodeExecutor.ts @@ -94,12 +94,13 @@ class LeetCodeExecutor implements Disposable { ); } - public async showProblem(problemNode: IProblem, language: string, outDir: string): Promise { + public async showProblem(problemNode: IProblem, language: string, outDir: string, detailed: boolean = false): Promise { 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); }