Skip to content

Commit b88a58e

Browse files
committed
feat: add command PickProblemToday, update version
1 parent 5b48fd9 commit b88a58e

File tree

5 files changed

+1614
-7
lines changed

5 files changed

+1614
-7
lines changed

.vscode/settings.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,12 @@
1010
".vscode-test": true
1111
},
1212
"tslint.autoFixOnSave": true,
13-
"tslint.ignoreDefinitionFiles": true
14-
}
13+
"tslint.ignoreDefinitionFiles": true,
14+
"editor.defaultFormatter": null,
15+
"[typescript]": {
16+
"editor.defaultFormatter": "vscode.typescript-language-features"
17+
},
18+
"[json]": {
19+
"editor.defaultFormatter": "vscode.json-language-features"
20+
}
21+
}

package.json

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"name": "vscode-leetcode",
3-
"displayName": "LeetCode",
4-
"description": "Solve LeetCode problems in VS Code",
5-
"version": "0.18.1",
2+
"name": "vscode-leetcode-dggua",
3+
"displayName": "LeetCodeEveryday",
4+
"description": "Solve LeetCode problems in VS Code EveryDay",
5+
"version": "0.19.0",
66
"author": "Sheng Chen",
7-
"publisher": "LeetCode",
7+
"publisher": "dggua",
88
"license": "MIT",
99
"icon": "resources/LeetCode.png",
1010
"engines": {
@@ -32,6 +32,7 @@
3232
"onCommand:leetcode.manageSessions",
3333
"onCommand:leetcode.refreshExplorer",
3434
"onCommand:leetcode.pickOne",
35+
"onCommand:leetcode.pickToday",
3536
"onCommand:leetcode.showProblem",
3637
"onCommand:leetcode.previewProblem",
3738
"onCommand:leetcode.searchProblem",
@@ -82,6 +83,11 @@
8283
"title": "Pick One",
8384
"category": "LeetCode"
8485
},
86+
{
87+
"command": "leetcode.pickToday",
88+
"title": "Pick Problem Today",
89+
"category": "LeetCode"
90+
},
8591
{
8692
"command": "leetcode.showProblem",
8793
"title": "Show Problem",

src/commands/show.ts

+12
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ export async function pickOne(): Promise<void> {
5252
await showProblemInternal(randomProblem);
5353
}
5454

55+
export async function pickToday(context: vscode.ExtensionContext): Promise<void> {
56+
const dailyProblems = await list.listDailyProblems(context);
57+
const problemToday = dailyProblems.find(problem => Number.parseInt(problem.date.split("-")[2]) == new Date().getDate())
58+
const problems: IProblem[] = await list.listProblems();
59+
const targetProblem = problems.find(problem => problem.id == problemToday?.question.questionFrontendId)
60+
if (!targetProblem) {
61+
vscode.window.showErrorMessage("Get problem today failed.");
62+
return;
63+
}
64+
await showProblemInternal(targetProblem)
65+
}
66+
5567
export async function showProblem(node?: LeetCodeNode): Promise<void> {
5668
if (!node) {
5769
return;

src/extension.ts

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
6060
vscode.commands.registerCommand("leetcode.previewProblem", (node: LeetCodeNode) => show.previewProblem(node)),
6161
vscode.commands.registerCommand("leetcode.showProblem", (node: LeetCodeNode) => show.showProblem(node)),
6262
vscode.commands.registerCommand("leetcode.pickOne", () => show.pickOne()),
63+
vscode.commands.registerCommand("leetcode.pickToday", () => show.pickToday(context)),
6364
vscode.commands.registerCommand("leetcode.searchProblem", () => show.searchProblem()),
6465
vscode.commands.registerCommand("leetcode.showSolution", (input: LeetCodeNode | vscode.Uri) => show.showSolution(input)),
6566
vscode.commands.registerCommand("leetcode.refreshExplorer", () => leetCodeTreeDataProvider.refresh()),

0 commit comments

Comments
 (0)