@@ -26,7 +26,7 @@ export async function searchProblem(): Promise<void> {
26
26
return ;
27
27
}
28
28
const problems :IProblem [ ] = await list . listProblems ( ) ;
29
- const choice :IQuickItemEx < string > | undefined = await vscode . window . showQuickPick (
29
+ const choice :IQuickItemEx < IProblem > | undefined = await vscode . window . showQuickPick (
30
30
parseProblemsToPicks ( problems ) ,
31
31
{
32
32
matchOnDetail :true ,
@@ -36,7 +36,7 @@ export async function searchProblem(): Promise<void> {
36
36
if ( ! choice ) {
37
37
return ;
38
38
}
39
- await showProblemInternal ( problems . find ( ( problem : IProblem ) => problem . id === choice . value ) as IProblem ) ;
39
+ await showProblemInternal ( choice . value ) ;
40
40
}
41
41
42
42
async function showProblemInternal ( node :IProblem ) :Promise < void > {
@@ -57,12 +57,22 @@ async function showProblemInternal(node: IProblem): Promise<void> {
57
57
if ( outputPath ) {
58
58
switch ( outputPath [ 1 ] . toLowerCase ( ) ) {
59
59
case "tag" :
60
- const closestTag :string = node . tags . reduce ( ( prev :string , curr :string ) => {
61
- return curr . length > prev . length ?
62
- curr :
63
- prev ;
64
- } , "" ) ;
65
- outDir = path . join ( outDir , closestTag ) ;
60
+ let tag :string | undefined ;
61
+ if ( node . tags . length === 1 ) {
62
+ tag = node . tags [ 0 ] ;
63
+ } else {
64
+ tag = await vscode . 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 ) ;
66
76
break ;
67
77
case "language" :
68
78
outDir = path . join ( outDir , language ) ;
@@ -108,13 +118,13 @@ async function showProblemInternal(node: IProblem): Promise<void> {
108
118
}
109
119
}
110
120
111
- async function parseProblemsToPicks ( p :IProblem [ ] ) :Promise < Array < IQuickItemEx < string > > > {
112
- return new Promise ( async ( resolve :( res :Array < IQuickItemEx < string > > ) => void ) :Promise < void > => {
113
- const picks :Array < IQuickItemEx < string > > = p . map ( ( problem :IProblem ) => Object . assign ( { } , {
121
+ async function parseProblemsToPicks ( p :IProblem [ ] ) :Promise < Array < IQuickItemEx < IProblem > > > {
122
+ return new Promise ( async ( resolve :( res :Array < IQuickItemEx < IProblem > > ) => void ) :Promise < void > => {
123
+ const picks :Array < IQuickItemEx < IProblem > > = p . map ( ( problem :IProblem ) => Object . assign ( { } , {
114
124
label :`${ parseProblemDecorator ( problem . state , problem . locked ) } ${ problem . id } .${ problem . name } ` ,
115
125
description :"" ,
116
126
detail :`AC rate:${ problem . passRate } , Difficulty:${ problem . difficulty } ` ,
117
- value :problem . id ,
127
+ value :problem ,
118
128
} ) ) ;
119
129
resolve ( picks ) ;
120
130
} ) ;