@@ -17,27 +17,50 @@ export async function listProblems(): Promise<IProblem[]> {
17
17
const showLocked : boolean = ! ! leetCodeConfig . get < boolean > ( "showLocked" ) ;
18
18
const useEndpointTranslation : boolean = settingUtils . shouldUseEndpointTranslation ( ) ;
19
19
const result : string = await leetCodeExecutor . listProblems ( showLocked , useEndpointTranslation ) ;
20
+ const resultE : string = await leetCodeExecutor . listProblems ( showLocked , false ) ;
20
21
const problems : IProblem [ ] = [ ] ;
21
22
const lines : string [ ] = result . split ( "\n" ) ;
23
+ const linesE : string [ ] = resultE . split ( "\n" ) ;
22
24
const reg : RegExp = / ^ ( .) \s ( .{ 1 , 2 } ) \s ( .) \s \[ \s * ( \d * ) \s * \] \s * ( .* ) \s * ( E a s y | M e d i u m | H a r d ) \s * \( ( \s * \d + \. \d + % ) \) / ;
23
25
const { companies, tags } = await leetCodeExecutor . getCompaniesAndTags ( ) ;
24
- for ( const line of lines ) {
26
+ for ( let i = 0 ; i < lines . length ; i ++ ) {
27
+ const line : string = lines [ i ]
28
+ const lineE : string = linesE [ i ]
25
29
const match : RegExpMatchArray | null = line . match ( reg ) ;
26
- if ( match && match . length === 8 ) {
30
+ const matchE : RegExpMatchArray | null = lineE . match ( reg ) ;
31
+ if ( match && match . length === 8 && matchE && matchE . length === 8 ) {
27
32
const id : string = match [ 4 ] . trim ( ) ;
28
33
problems . push ( {
29
34
id,
30
35
isFavorite : match [ 1 ] . trim ( ) . length > 0 ,
31
36
locked : match [ 2 ] . trim ( ) . length > 0 ,
32
37
state : parseProblemState ( match [ 3 ] ) ,
33
38
name : match [ 5 ] . trim ( ) ,
39
+ enName : matchE [ 5 ] . trim ( ) ,
34
40
difficulty : match [ 6 ] . trim ( ) ,
35
41
passRate : match [ 7 ] . trim ( ) ,
36
42
companies : companies [ id ] || [ "Unknown" ] ,
37
43
tags : tags [ id ] || [ "Unknown" ] ,
38
44
} ) ;
39
45
}
40
46
}
47
+ // for (const line of lines) {
48
+ // const match: RegExpMatchArray | null = line.match(reg);
49
+ // if (match && match.length === 8) {
50
+ // const id: string = match[4].trim();
51
+ // problems.push({
52
+ // id,
53
+ // isFavorite: match[1].trim().length > 0,
54
+ // locked: match[2].trim().length > 0,
55
+ // state: parseProblemState(match[3]),
56
+ // name: match[5].trim(),
57
+ // difficulty: match[6].trim(),
58
+ // passRate: match[7].trim(),
59
+ // companies: companies[id] || ["Unknown"],
60
+ // tags: tags[id] || ["Unknown"],
61
+ // });
62
+ // }
63
+ // }
41
64
return problems . reverse ( ) ;
42
65
} catch ( error ) {
43
66
await promptForOpenOutputChannel ( "Failed to list problems. Please open the output channel for details." , DialogType . error ) ;
0 commit comments