Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit927481a

Browse files
sheche@microsoft.comsheche@microsoft.com
sheche@microsoft.com
authored and
sheche@microsoft.com
committed
support setting the default language preference
1 parent142b36c commit927481a

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

‎package.json

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,41 @@
118118
"when":"never"
119119
}
120120
]
121-
}
121+
},
122+
"configuration": [
123+
{
124+
"title":"LeetCode",
125+
"properties": {
126+
"leetcode.defaultLanguage": {
127+
"type":"string",
128+
"enum": [
129+
"bash",
130+
"c",
131+
"cpp",
132+
"csharp",
133+
"golang",
134+
"java",
135+
"javascript",
136+
"kotlin",
137+
"mysql",
138+
"python",
139+
"python3",
140+
"ruby",
141+
"scala",
142+
"swift"
143+
],
144+
"scope":"window",
145+
"description":"Default language preference for solving the problems."
146+
},
147+
"leetcode.showSetDefaultLanguageHint": {
148+
"type":"boolean",
149+
"default":true,
150+
"scope":"window",
151+
"description":"Show a hint to let user set the default language preference."
152+
}
153+
}
154+
}
155+
]
122156
},
123157
"scripts": {
124158
"vscode:prepublish":"npm run compile",

‎src/commands/show.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { LeetCodeNode } from "../leetCodeExplorer";
66
import{leetCodeManager}from"../leetCodeManager";
77
import{IQuickItemEx,languages,leetCodeBinaryPath}from"../shared";
88
import{executeCommand}from"../utils/cpUtils";
9-
import{DialogType,promptForOpenOutputChannel,promptForSignIn}from"../utils/uiUtils";
9+
import{DialogOptions,DialogType,promptForOpenOutputChannel,promptForSignIn}from"../utils/uiUtils";
1010
import{selectWorkspaceFolder}from"../utils/workspaceUtils";
1111
import*aslistfrom"./list";
1212

@@ -37,10 +37,25 @@ export async function searchProblem(channel: vscode.OutputChannel): Promise<void
3737

3838
asyncfunctionshowProblemInternal(channel:vscode.OutputChannel,id:string):Promise<void>{
3939
try{
40-
constlanguage:string|undefined=awaitvscode.window.showQuickPick(languages,{placeHolder:"Select the language you want to use"});
40+
constleetCodeConfig:vscode.WorkspaceConfiguration=vscode.workspace.getConfiguration("leetcode");
41+
constdefaultLanguage=leetCodeConfig.get<string>("defaultLanguage");
42+
constlanguage:string|undefined=defaultLanguage||awaitvscode.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+
constchoice:vscode.MessageItem|undefined=awaitvscode.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+
}elseif(choice===DialogOptions.never){
56+
leetCodeConfig.update("showSetDefaultLanguageHint",false,true/* UserSetting */);
57+
}
58+
}
4459
constoutdir:string=awaitselectWorkspaceFolder();
4560
awaitfse.ensureDir(outdir);
4661
constresult:string=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"show",id,"-gx","-l",language,"-o",outdir]);

‎src/utils/uiUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export namespace DialogOptions {
77
exportconstopen:vscode.MessageItem={title:"Open"};
88
exportconstyes:vscode.MessageItem={title:"Yes"};
99
exportconstno:vscode.MessageItem={title:"No",isCloseAffordance:true};
10+
exportconstnever:vscode.MessageItem={title:"Never"};
1011
exportconstsingUp:vscode.MessageItem={title:"Sign up"};
1112
}
1213

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp