Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 99cb09b

Browse files
author
chengruilin
committed
feat: update outputPath api
1 parent 99dcf76 commit 99cb09b

File tree

3 files changed

+28
-25
lines changed

3 files changed

+28
-25
lines changed

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,16 @@
114114

115115

116116
## Settings
117-
| Setting Name | Description | Default Value |
118-
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
119-
| `leetcode.hideSolved` | Specify to hide the solved problems or not | `false` |
120-
| `leetcode.showLocked` | Specify to show the locked problems or not. Only Premium users could open the locked problems | `false` |
121-
| `leetcode.defaultLanguage` | Specify the default language used to solve the problem. Supported languages are: `bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `python`,`python3`,`ruby`,`scala`,`swift` | `N/A` |
122-
| `leetcode.useWsl` | Specify whether to use WSL or not | `false` |
123-
| `leetcode.endpoint` | Specify the active endpoint. Supported endpoints are: `leetcode`, `leetcode-cn` | `leetcode` |
124-
| `leetcode.outputPath` | * `${tag}` - a directory based on the problem's tag. For example, if the problem belongs to: `Binary Indexed Tree`, then a folder named `binary_indexed_tree` will be used here. |
125-
* `${language}` - a directory based on the language used. For example, `java` for Java language
126-
* `${difficulty}` - a directory based on the problem's difficulty. For example, `easy`
127-
* If this setting is not set, the files will be generated to the base path of the workspace folder | `root` |
117+
| Setting Name | Description | Default Value |
118+
|---|---|---|
119+
| `leetcode.hideSolved` | Specify to hide the solved problems or not | `false` |
120+
| `leetcode.showLocked` | Specify to show the locked problems or not. Only Premium users could open the locked problems | `false` |
121+
| `leetcode.defaultLanguage` | Specify the default language used to solve the problem. Supported languages are: `bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `python`,`python3`,`ruby`,`scala`,`swift` | `N/A` |
122+
| `leetcode.useWsl` | Specify whether to use WSL or not | `false` |
123+
| `leetcode.endpoint` | Specify the active endpoint. Supported endpoints are: `leetcode`, `leetcode-cn` | `leetcode` |
124+
125+
## Troubleshooting
126+
When you meet any problem, you can check the [Troubleshooting page](https://github.com/jdneo/vscode-leetcode/wiki/Troubleshooting) first.
128127

129128
## Release Notes
130129

package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,8 @@
250250
},
251251
"leetcode.outputPath": {
252252
"type": "string",
253-
"default": "root",
253+
"default": "",
254254
"scope": "application",
255-
"enum": [
256-
"root",
257-
"tag",
258-
"language",
259-
"difficulty"
260-
],
261255
"description": "Specifies the relative path to save the problem files."
262256
}
263257
}

src/commands/show.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export async function searchProblem(): Promise<void> {
3939

4040
async function showProblemInternal(id: string): Promise<void> {
4141
try {
42+
const listProblems: IProblem[] = await list.listProblems();
4243
const leetCodeConfig: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("leetcode");
4344
let defaultLanguage: string | undefined = leetCodeConfig.get<string>("defaultLanguage");
4445
if (defaultLanguage && languages.indexOf(defaultLanguage) < 0) {
@@ -50,21 +51,30 @@ async function showProblemInternal(id: string): Promise<void> {
5051
}
5152

5253
let outDir: string = await selectWorkspaceFolder();
53-
const outputPath: string = leetCodeConfig.get<string>("outputPath") || "root";
54+
const outputPath: string = leetCodeConfig.get<string>("outputPath") || "";
55+
const problem: IProblem | undefined = listProblems.find((item: IProblem) => item.id === id);
5456
switch (outputPath) {
55-
case "root": {
57+
case "": {
5658
break;
5759
}
58-
case "tag": {
59-
const { tags } = await leetCodeExecutor.getCompaniesAndTags();
60-
outDir = `${outDir}/${tags[id][0].split("-").map((c: string) => c[0].toUpperCase() + c.slice(1)).join("")}`;
60+
case "${tag}": {
61+
if (problem) {
62+
outDir = `${outDir}/${problem.tags[0]}`;
63+
}
6164
break;
6265
}
63-
case "language": {
66+
case "${language}": {
6467
outDir = `${outDir}/${language}`;
6568
break;
6669
}
67-
case "difficulty": {
70+
case "${difficulty}": {
71+
if (problem) {
72+
outDir = `${outDir}/${problem.difficulty}`;
73+
}
74+
break;
75+
}
76+
default: {
77+
outDir = `${outDir}/${outputPath}`;
6878
break;
6979
}
7080
}

0 commit comments

Comments
 (0)