@@ -46,6 +46,18 @@ async function showProblemInternal(channel: vscode.OutputChannel, id: string): P
4646if ( ! language ) {
4747return ;
4848}
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+
4961if ( ! defaultLanguage && leetCodeConfig . get < boolean > ( "showSetDefaultLanguageHint" ) ) {
5062const choice :vscode . MessageItem | undefined = await vscode . window . showInformationMessage (
5163`Would you like to set '${ language } ' as your default language?` ,
@@ -59,16 +71,6 @@ async function showProblemInternal(channel: vscode.OutputChannel, id: string): P
5971leetCodeConfig . update ( "showSetDefaultLanguageHint" , false , true /* UserSetting */ ) ;
6072}
6173}
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- }
7274} catch ( error ) {
7375await promptForOpenOutputChannel ( "Failed to fetch the problem information. Please open the output channel for details" , DialogType . error , channel ) ;
7476}