@@ -12,6 +12,8 @@ import { leetCodeExecutor } from "../leetCodeExecutor";
1212import { leetCodeManager } from "../leetCodeManager" ;
1313import { IProblem , IQuickItemEx , languages , ProblemState } from "../shared" ;
1414import { genFileExt , genFileName , getNodeIdFromFile } from "../utils/problemUtils" ;
15+ import * as settingUtils from "../utils/settingUtils" ;
16+ import { IDescriptionConfiguration } from "../utils/settingUtils" ;
1517import { DialogOptions , DialogType , openSettingsEditor , promptForOpenOutputChannel , promptForSignIn , promptHintMessage } from "../utils/uiUtils" ;
1618import { getActiveFilePath , selectWorkspaceFolder } from "../utils/workspaceUtils" ;
1719import * as wsl from "../utils/wslUtils" ;
@@ -166,28 +168,30 @@ async function showProblemInternal(node: IProblem): Promise<void> {
166168
167169 finalPath = wsl . useWsl ( ) ? await wsl . toWinPath ( finalPath ) : finalPath ;
168170
169- await leetCodeExecutor . showProblem ( node , language , finalPath , leetCodeConfig . get < boolean > ( "showCommentDescription" ) ) ;
170- await Promise . all ( [
171+ const descriptionConfig : IDescriptionConfiguration = settingUtils . getDescriptionConfiguration ( ) ;
172+ await leetCodeExecutor . showProblem ( node , language , finalPath , descriptionConfig . showInComment ) ;
173+ const promises : any [ ] = [
171174 vscode . window . showTextDocument ( vscode . Uri . file ( finalPath ) , { preview : false , viewColumn : vscode . ViewColumn . One } ) ,
172- movePreviewAsideIfNeeded ( node ) ,
173175 promptHintMessage (
174176 "hint.commentDescription" ,
175- 'You can generate the code file with problem description in the comments by enabling "leetcode.showCommentDescription ".' ,
177+ 'You can config how to show the problem description through "leetcode.showDescription ".' ,
176178 "Open settings" ,
177- ( ) : Promise < any > => openSettingsEditor ( "leetcode.showCommentDescription " ) ,
179+ ( ) : Promise < any > => openSettingsEditor ( "leetcode.showDescription " ) ,
178180 ) ,
179- ] ) ;
181+ ] ;
182+ if ( descriptionConfig . showInWebview ) {
183+ promises . push ( showDescriptionView ( node ) ) ;
184+ }
185+
186+ await Promise . all ( promises ) ;
180187 } catch ( error ) {
181188 await promptForOpenOutputChannel ( `${ error } Please open the output channel for details.` , DialogType . error ) ;
182189 }
183190}
184191
185- async function movePreviewAsideIfNeeded ( node : IProblem ) : Promise < void > {
186- if ( vscode . workspace . getConfiguration ( "leetcode" ) . get < boolean > ( "enableSideMode" , true ) ) {
187- return previewProblem ( node , true ) ;
188- }
192+ async function showDescriptionView ( node : IProblem ) : Promise < void > {
193+ return previewProblem ( node , vscode . workspace . getConfiguration ( "leetcode" ) . get < boolean > ( "enableSideMode" , true ) ) ;
189194}
190-
191195async function parseProblemsToPicks ( p : Promise < IProblem [ ] > ) : Promise < Array < IQuickItemEx < IProblem > > > {
192196 return new Promise ( async ( resolve : ( res : Array < IQuickItemEx < IProblem > > ) => void ) : Promise < void > => {
193197 const picks : Array < IQuickItemEx < IProblem > > = ( await p ) . map ( ( problem : IProblem ) => Object . assign ( { } , {
0 commit comments