From 4f81063a363b1959f5c65d6a42962cd6f1360fff Mon Sep 17 00:00:00 2001
From: Vigilans <vigilans@foxmail.com>
Date: Tue, 23 Apr 2019 18:59:06 +0800
Subject: [PATCH 1/3] Add `showCommentDescription` config

---
 package.json            | 6 ++++++
 src/commands/show.ts    | 2 +-
 src/leetCodeExecutor.ts | 5 +++--
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/package.json b/package.json
index 7f8d6368..10efa3d7 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": "Determine whether to generate problem description as comment in code file."
+                    },
                     "leetcode.showSetDefaultLanguageHint": {
                         "type": "boolean",
                         "default": true,
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<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 }),
diff --git a/src/leetCodeExecutor.ts b/src/leetCodeExecutor.ts
index a142fbf2..24604714 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<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);
         }
 

From cd6264ae453c1feff02123d20f06716801e16539 Mon Sep 17 00:00:00 2001
From: Vigilans <vigilans@foxmail.com>
Date: Sat, 27 Apr 2019 17:43:14 +0800
Subject: [PATCH 2/3] Resolve review

---
 package.json            | 2 +-
 src/leetCodeExecutor.ts | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/package.json b/package.json
index 10efa3d7..938358ba 100644
--- a/package.json
+++ b/package.json
@@ -266,7 +266,7 @@
                         "type": "boolean",
                         "default": false,
                         "scope": "application",
-                        "description": "Determine whether to generate problem description as comment in code file."
+                        "description": "Include problem description in comments."
                     },
                     "leetcode.showSetDefaultLanguageHint": {
                         "type": "boolean",
diff --git a/src/leetCodeExecutor.ts b/src/leetCodeExecutor.ts
index 24604714..27b896c1 100644
--- a/src/leetCodeExecutor.ts
+++ b/src/leetCodeExecutor.ts
@@ -97,10 +97,10 @@ class LeetCodeExecutor implements Disposable {
     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";
+        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, codeType, "-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);
         }
 

From ab9f24790bda7e95f25510fe267873f08dc5899f Mon Sep 17 00:00:00 2001
From: Vigilans <vigilans@foxmail.com>
Date: Sat, 27 Apr 2019 18:12:28 +0800
Subject: [PATCH 3/3] Update leetcode-cli dependency

---
 package-lock.json | 16 ++++++----------
 package.json      |  2 +-
 2 files changed, 7 insertions(+), 11 deletions(-)

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 938358ba..ce3476a8 100644
--- a/package.json
+++ b/package.json
@@ -350,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"
     }
 }