@@ -6,7 +6,7 @@ import { LeetCodeNode } from "../leetCodeExplorer";
66import { leetCodeManager } from "../leetCodeManager" ;
77import { IQuickItemEx , languages , leetCodeBinaryPath } from "../shared" ;
88import { executeCommand } from "../utils/cpUtils" ;
9- import { DialogType , promptForOpenOutputChannel , promptForSignIn } from "../utils/uiUtils" ;
9+ import { DialogOptions , DialogType , promptForOpenOutputChannel , promptForSignIn } from "../utils/uiUtils" ;
1010import { selectWorkspaceFolder } from "../utils/workspaceUtils" ;
1111import * as list from "./list" ;
1212
@@ -37,10 +37,28 @@ export async function searchProblem(channel: vscode.OutputChannel): Promise<void
3737
3838async function showProblemInternal ( channel : vscode . OutputChannel , id : string ) : Promise < void > {
3939 try {
40- const language : string | undefined = await vscode . window . showQuickPick ( languages , { placeHolder : "Select the language you want to use" } ) ;
40+ const leetCodeConfig : vscode . WorkspaceConfiguration = vscode . workspace . getConfiguration ( "leetcode" ) ;
41+ let defaultLanguage = leetCodeConfig . get < string > ( "defaultLanguage" ) ;
42+ if ( defaultLanguage && languages . indexOf ( defaultLanguage ) < 0 ) {
43+ defaultLanguage = undefined ;
44+ }
45+ const language : string | undefined = defaultLanguage || await vscode . window . showQuickPick ( languages , { placeHolder : "Select the language you want to use" } ) ;
4146 if ( ! language ) {
4247 return ;
4348 }
49+ if ( ! defaultLanguage && leetCodeConfig . get < boolean > ( "showSetDefaultLanguageHint" ) ) {
50+ const choice : vscode . MessageItem | undefined = await vscode . window . showInformationMessage (
51+ `Would you like to set '${ language } ' as your default language?` ,
52+ DialogOptions . yes ,
53+ DialogOptions . no ,
54+ DialogOptions . never ,
55+ ) ;
56+ if ( choice === DialogOptions . yes ) {
57+ leetCodeConfig . update ( "defaultLanguage" , language , true /* UserSetting */ ) ;
58+ } else if ( choice === DialogOptions . never ) {
59+ leetCodeConfig . update ( "showSetDefaultLanguageHint" , false , true /* UserSetting */ ) ;
60+ }
61+ }
4462 const outdir : string = await selectWorkspaceFolder ( ) ;
4563 await fse . ensureDir ( outdir ) ;
4664 const result : string = await executeCommand ( channel , "node" , [ leetCodeBinaryPath , "show" , id , "-gx" , "-l" , language , "-o" , outdir ] ) ;
0 commit comments