@@ -12,6 +12,8 @@ import { leetCodeExecutor } from "../leetCodeExecutor";
12
12
import { leetCodeManager } from "../leetCodeManager" ;
13
13
import { IProblem , IQuickItemEx , languages , ProblemState } from "../shared" ;
14
14
import { genFileExt , genFileName , getNodeIdFromFile } from "../utils/problemUtils" ;
15
+ import * as settingUtils from "../utils/settingUtils" ;
16
+ import { IDescriptionConfiguration } from "../utils/settingUtils" ;
15
17
import { DialogOptions , DialogType , openSettingsEditor , promptForOpenOutputChannel , promptForSignIn , promptHintMessage } from "../utils/uiUtils" ;
16
18
import { getActiveFilePath , selectWorkspaceFolder } from "../utils/workspaceUtils" ;
17
19
import * as wsl from "../utils/wslUtils" ;
@@ -166,28 +168,30 @@ async function showProblemInternal(node: IProblem): Promise<void> {
166
168
167
169
finalPath = wsl . useWsl ( ) ? await wsl . toWinPath ( finalPath ) : finalPath ;
168
170
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 [ ] = [
171
174
vscode . window . showTextDocument ( vscode . Uri . file ( finalPath ) , { preview : false , viewColumn : vscode . ViewColumn . One } ) ,
172
- movePreviewAsideIfNeeded ( node ) ,
173
175
promptHintMessage (
174
176
"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 ".' ,
176
178
"Open settings" ,
177
- ( ) : Promise < any > => openSettingsEditor ( "leetcode.showCommentDescription " ) ,
179
+ ( ) : Promise < any > => openSettingsEditor ( "leetcode.showDescription " ) ,
178
180
) ,
179
- ] ) ;
181
+ ] ;
182
+ if ( descriptionConfig . showInWebview ) {
183
+ promises . push ( showDescriptionView ( node ) ) ;
184
+ }
185
+
186
+ await Promise . all ( promises ) ;
180
187
} catch ( error ) {
181
188
await promptForOpenOutputChannel ( `${ error } Please open the output channel for details.` , DialogType . error ) ;
182
189
}
183
190
}
184
191
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 ) ) ;
189
194
}
190
-
191
195
async function parseProblemsToPicks ( p : Promise < IProblem [ ] > ) : Promise < Array < IQuickItemEx < IProblem > > > {
192
196
return new Promise ( async ( resolve : ( res : Array < IQuickItemEx < IProblem > > ) => void ) : Promise < void > => {
193
197
const picks : Array < IQuickItemEx < IProblem > > = ( await p ) . map ( ( problem : IProblem ) => Object . assign ( { } , {
0 commit comments