@@ -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,25 @@ 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+ const defaultLanguage = leetCodeConfig . get < string > ( "defaultLanguage" ) ;
42+ const language : string | undefined = defaultLanguage || await vscode . window . showQuickPick ( languages , { placeHolder : "Select the language you want to use" } ) ;
4143 if ( ! language ) {
4244 return ;
4345 }
46+ if ( ! defaultLanguage && leetCodeConfig . get < boolean > ( "showSetDefaultLanguageHint" ) ) {
47+ const choice : vscode . MessageItem | undefined = await vscode . window . showInformationMessage (
48+ `Would you like to set '${ language } ' as your default language?` ,
49+ DialogOptions . yes ,
50+ DialogOptions . no ,
51+ DialogOptions . never ,
52+ ) ;
53+ if ( choice === DialogOptions . yes ) {
54+ leetCodeConfig . update ( "defaultLanguage" , language , true /* UserSetting */ ) ;
55+ } else if ( choice === DialogOptions . never ) {
56+ leetCodeConfig . update ( "showSetDefaultLanguageHint" , false , true /* UserSetting */ ) ;
57+ }
58+ }
4459 const outdir : string = await selectWorkspaceFolder ( ) ;
4560 await fse . ensureDir ( outdir ) ;
4661 const result : string = await executeCommand ( channel , "node" , [ leetCodeBinaryPath , "show" , id , "-gx" , "-l" , language , "-o" , outdir ] ) ;
0 commit comments