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

Commite353202

Browse files
committed
feat: add tag selector
1 parent107fea6 commite353202

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

‎src/commands/show.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function searchProblem(): Promise<void> {
2626
return;
2727
}
2828
constproblems:IProblem[]=awaitlist.listProblems();
29-
constchoice:IQuickItemEx<string>|undefined=awaitvscode.window.showQuickPick(
29+
constchoice:IQuickItemEx<IProblem>|undefined=awaitvscode.window.showQuickPick(
3030
parseProblemsToPicks(problems),
3131
{
3232
matchOnDetail:true,
@@ -36,7 +36,7 @@ export async function searchProblem(): Promise<void> {
3636
if(!choice){
3737
return;
3838
}
39-
awaitshowProblemInternal(problems.find((problem:IProblem)=>problem.id===choice.value)asIProblem);
39+
awaitshowProblemInternal(choice.value);
4040
}
4141

4242
asyncfunctionshowProblemInternal(node:IProblem):Promise<void>{
@@ -57,12 +57,22 @@ async function showProblemInternal(node: IProblem): Promise<void> {
5757
if(outputPath){
5858
switch(outputPath[1].toLowerCase()){
5959
case"tag":
60-
constclosestTag:string=node.tags.reduce((prev:string,curr:string)=>{
61-
returncurr.length>prev.length ?
62-
curr :
63-
prev;
64-
},"");
65-
outDir=path.join(outDir,closestTag);
60+
lettag:string|undefined;
61+
if(node.tags.length===1){
62+
tag=node.tags[0];
63+
}else{
64+
tag=awaitvscode.window.showQuickPick(
65+
node.tags,
66+
{
67+
matchOnDetail:true,
68+
placeHolder:"Select one tag",
69+
},
70+
);
71+
}
72+
if(!tag){
73+
return;
74+
}
75+
outDir=path.join(outDir,tag);
6676
break;
6777
case"language":
6878
outDir=path.join(outDir,language);
@@ -108,13 +118,13 @@ async function showProblemInternal(node: IProblem): Promise<void> {
108118
}
109119
}
110120

111-
asyncfunctionparseProblemsToPicks(p:IProblem[]):Promise<Array<IQuickItemEx<string>>>{
112-
returnnewPromise(async(resolve:(res:Array<IQuickItemEx<string>>)=>void):Promise<void>=>{
113-
constpicks:Array<IQuickItemEx<string>>=p.map((problem:IProblem)=>Object.assign({},{
121+
asyncfunctionparseProblemsToPicks(p:IProblem[]):Promise<Array<IQuickItemEx<IProblem>>>{
122+
returnnewPromise(async(resolve:(res:Array<IQuickItemEx<IProblem>>)=>void):Promise<void>=>{
123+
constpicks:Array<IQuickItemEx<IProblem>>=p.map((problem:IProblem)=>Object.assign({},{
114124
label:`${parseProblemDecorator(problem.state,problem.locked)}${problem.id}.${problem.name}`,
115125
description:"",
116126
detail:`AC rate:${problem.passRate}, Difficulty:${problem.difficulty}`,
117-
value:problem.id,
127+
value:problem,
118128
}));
119129
resolve(picks);
120130
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp