Movatterモバイル変換


[0]ホーム

URL:


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

Commit89e5eca

Browse files
committed
feat: add outputPath config
1 parent90c6d09 commit89e5eca

File tree

5 files changed

+38
-21
lines changed

5 files changed

+38
-21
lines changed

‎README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@
6767
<imgsrc="https://raw.githubusercontent.com/jdneo/vscode-leetcode/master/docs/imgs/pick_problem.png"alt="Pick a Problem" />
6868
</p>
6969

70-
- Right click the problem in the`LeetCode Explorer` and select`Show problem` will generate a new file with the problem description for you.
71-
- Right click the problem in the`LeetCode Explorer` and select`Show problem with tag` will generate a new file with the problem description and classified by tag folder.
70+
- Right click the problem in the`LeetCode Explorer` and select`Show Problem` will generate a new file with the problem description for you.
7271

7372
>Note: If no folder is opened in VS Code, the extension will save the problem files in**$HOME/.leetcode/**.
7473
@@ -122,6 +121,10 @@
122121
|`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`|
123122
|`leetcode.useWsl`| Specify whether to use WSL or not|`false`|
124123
|`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` |
125128

126129
##Release Notes
127130

‎docs/README_zh-CN.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@
6767
<imgsrc="https://raw.githubusercontent.com/jdneo/vscode-leetcode/master/docs/imgs/pick_problem.png"alt="选择题目" />
6868
</p>
6969

70-
-`LeetCode Explorer`**右键**题目并选择`Show problem` 进行答题。
71-
-`LeetCode Explorer`**右键**题目并选择`Show problem with tag`,题目会被放进分类好的文件夹,并进行答题。
70+
-`LeetCode Explorer`**右键**题目并选择`Show Problem` 进行答题。
7271

7372
>注意:若当前 VS Code 没有已打开的文件夹,则生成的题目文件会存储于**$HOME/.leetcode/** 目录下。
7473

‎package.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@
9393
"title":"Show Problem",
9494
"category":"LeetCode"
9595
},
96-
{
97-
"command":"leetcode.showProblemWithTag",
98-
"title":"Show problem with tag",
99-
"category":"LeetCode"
100-
},
10196
{
10297
"command":"leetcode.searchProblem",
10398
"title":"Search Problem",
@@ -163,11 +158,6 @@
163158
"command":"leetcode.showProblem",
164159
"when":"view == leetCodeExplorer && viewItem == problem",
165160
"group":"leetcode@1"
166-
},
167-
{
168-
"command":"leetcode.showProblemWithTag",
169-
"when":"view == leetCodeExplorer && viewItem == problem",
170-
"group":"leetcode@1"
171161
}
172162
],
173163
"commandPalette": [
@@ -257,6 +247,18 @@
257247
"leetcode-cn"
258248
],
259249
"description":"Endpoint of the user account."
250+
},
251+
"leetcode.outputPath": {
252+
"type":"string",
253+
"default":"root",
254+
"scope":"application",
255+
"enum": [
256+
"root",
257+
"tag",
258+
"language",
259+
"difficulty"
260+
],
261+
"description":"Specifies the relative path to save the problem files."
260262
}
261263
}
262264
}

‎src/commands/show.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import { selectWorkspaceFolder } from "../utils/workspaceUtils";
1212
import*aswslfrom"../utils/wslUtils";
1313
import*aslistfrom"./list";
1414

15-
exportasyncfunctionshowProblem(node?:LeetCodeNode,withTagFloder?:boolean):Promise<void>{
15+
exportasyncfunctionshowProblem(node?:LeetCodeNode):Promise<void>{
1616
if(!node){
1717
return;
1818
}
19-
awaitshowProblemInternal(node.id,withTagFloder);
19+
awaitshowProblemInternal(node.id);
2020
}
2121

2222
exportasyncfunctionsearchProblem():Promise<void>{
@@ -37,7 +37,7 @@ export async function searchProblem(): Promise<void> {
3737
awaitshowProblemInternal(choice.value);
3838
}
3939

40-
asyncfunctionshowProblemInternal(id:string,withTagFloder?:boolean):Promise<void>{
40+
asyncfunctionshowProblemInternal(id:string):Promise<void>{
4141
try{
4242
constleetCodeConfig:vscode.WorkspaceConfiguration=vscode.workspace.getConfiguration("leetcode");
4343
letdefaultLanguage:string|undefined=leetCodeConfig.get<string>("defaultLanguage");
@@ -50,9 +50,23 @@ async function showProblemInternal(id: string, withTagFloder?: boolean): Promise
5050
}
5151

5252
letoutDir:string=awaitselectWorkspaceFolder();
53-
if(withTagFloder){
54-
const{ tags}=awaitleetCodeExecutor.getCompaniesAndTags();
55-
outDir=`${outDir}/${tags[id][0].split("-").map((c:string)=>c[0].toUpperCase()+c.slice(1)).join(" ")}`;
53+
constoutputPath:string=leetCodeConfig.get<string>("outputPath")||"root";
54+
switch(outputPath){
55+
case"root":{
56+
break;
57+
}
58+
case"tag":{
59+
const{ tags}=awaitleetCodeExecutor.getCompaniesAndTags();
60+
outDir=`${outDir}/${tags[id][0].split("-").map((c:string)=>c[0].toUpperCase()+c.slice(1)).join("")}`;
61+
break;
62+
}
63+
case"language":{
64+
outDir=`${outDir}/${language}`;
65+
break;
66+
}
67+
case"difficulty":{
68+
break;
69+
}
5670
}
5771
awaitfse.ensureDir(outDir);
5872
constresult:string=awaitleetCodeExecutor.showProblem(id,language,outDir);

‎src/extension.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
4343
vscode.commands.registerCommand("leetcode.selectSessions",()=>session.selectSession()),
4444
vscode.commands.registerCommand("leetcode.createSession",()=>session.createSession()),
4545
vscode.commands.registerCommand("leetcode.showProblem",(node:LeetCodeNode)=>show.showProblem(node)),
46-
vscode.commands.registerCommand("leetcode.showProblemWithTag",(node:LeetCodeNode)=>show.showProblem(node,true)),
4746
vscode.commands.registerCommand("leetcode.searchProblem",()=>show.searchProblem()),
4847
vscode.commands.registerCommand("leetcode.refreshExplorer",()=>leetCodeTreeDataProvider.refresh()),
4948
vscode.commands.registerCommand("leetcode.testSolution",(uri?:vscode.Uri)=>test.testSolution(uri)),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp