@@ -46,6 +46,18 @@ async function showProblemInternal(channel: vscode.OutputChannel, id: string): P
46
46
if ( ! language ) {
47
47
return ;
48
48
}
49
+
50
+ const outdir : string = await selectWorkspaceFolder ( ) ;
51
+ await fse . ensureDir ( outdir ) ;
52
+ const result : string = await executeCommand ( channel , "node" , [ leetCodeBinaryPath , "show" , id , "-gx" , "-l" , language , "-o" , outdir ] ) ;
53
+ const reg : RegExp = / \* S o u r c e C o d e : \s * ( .* ) / ;
54
+ const match : RegExpMatchArray | null = result . match ( reg ) ;
55
+ if ( match && match . length >= 2 ) {
56
+ await vscode . window . showTextDocument ( vscode . Uri . file ( match [ 1 ] . trim ( ) ) , { preview : false } ) ;
57
+ } else {
58
+ throw new Error ( "Failed to fetch the problem information" ) ;
59
+ }
60
+
49
61
if ( ! defaultLanguage && leetCodeConfig . get < boolean > ( "showSetDefaultLanguageHint" ) ) {
50
62
const choice : vscode . MessageItem | undefined = await vscode . window . showInformationMessage (
51
63
`Would you like to set '${ language } ' as your default language?` ,
@@ -59,16 +71,6 @@ async function showProblemInternal(channel: vscode.OutputChannel, id: string): P
59
71
leetCodeConfig . update ( "showSetDefaultLanguageHint" , false , true /* UserSetting */ ) ;
60
72
}
61
73
}
62
- const outdir : string = await selectWorkspaceFolder ( ) ;
63
- await fse . ensureDir ( outdir ) ;
64
- const result : string = await executeCommand ( channel , "node" , [ leetCodeBinaryPath , "show" , id , "-gx" , "-l" , language , "-o" , outdir ] ) ;
65
- const reg : RegExp = / \* S o u r c e C o d e : \s * ( .* ) / ;
66
- const match : RegExpMatchArray | null = result . match ( reg ) ;
67
- if ( match && match . length >= 2 ) {
68
- await vscode . window . showTextDocument ( vscode . Uri . file ( match [ 1 ] . trim ( ) ) , { preview : false } ) ;
69
- } else {
70
- throw new Error ( "Failed to fetch the problem information" ) ;
71
- }
72
74
} catch ( error ) {
73
75
await promptForOpenOutputChannel ( "Failed to fetch the problem information. Please open the output channel for details" , DialogType . error , channel ) ;
74
76
}
0 commit comments