Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: LeetCode-OpenSource/vscode-leetcode
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: supengxu/vscode-leetcode
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 2 commits
  • 10 files changed
  • 1 contributor

Commits on May 13, 2025

  1. refactor(explorer): 重构 Hot100 和 Interview Classics 150 的获取方式

    -从 explorerNodeManager.ts 中移除直接调用接口获取 Hot100 和 Interview Classics 150 数据的逻辑
    - 在 LeetCodeNode.ts 中添加 isHot100 和 isClassic150属性,用于判断节点是否属于 Hot100 或 Classic150
    - 更新 list.ts,将 Hot100 和 Interview Classics 150 的数据作为问题列表的一部分进行处理
    - 在 shared.ts 中为 IProblem 接口添加 isHot100 和 isClassic150 字段
    
    暂存
    xusupeng committed May 13, 2025
    Copy the full SHA
    3f83267 View commit details

Commits on Jun 2, 2025

  1. feat(explorer): 添加英文题目名称支持

    在问题列表和展示功能中增加英文题目名称字段,用于生成不同格式的路径名称
    修改相关接口和逻辑以支持中英文题目名称切换
    xusupeng committed Jun 2, 2025
    Copy the full SHA
    5ab223b View commit details
Showing with 358 additions and 5 deletions.
  1. +13 −0 .idea/.gitignore
  2. +8 −0 .idea/indexLayout.xml
  3. +6 −0 .idea/vcs.xml
  4. +271 −2 src/commands/list.ts
  5. +3 −3 src/commands/show.ts
  6. +9 −0 src/explorer/LeetCodeNode.ts
  7. +4 −0 src/explorer/LeetCodeTreeDataProvider.ts
  8. +28 −0 src/explorer/explorerNodeManager.ts
  9. +8 −0 src/leetCodeExecutor.ts
  10. +8 −0 src/shared.ts
13 changes: 13 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

273 changes: 271 additions & 2 deletions src/commands/list.ts
Original file line number Diff line number Diff line change
@@ -7,17 +7,283 @@ import { IProblem, ProblemState, UserStatus } from "../shared";
import * as settingUtils from "../utils/settingUtils";
import { DialogType, promptForOpenOutputChannel } from "../utils/uiUtils";


export async function listProblems(): Promise<IProblem[]> {
try {
if (leetCodeManager.getStatus() === UserStatus.SignedOut) {
return [];
}

const useEndpointTranslation: boolean = settingUtils.shouldUseEndpointTranslation();
const result: string = await leetCodeExecutor.listProblems(true, useEndpointTranslation);
let result = await leetCodeExecutor.listProblems(true, useEndpointTranslation);
let resultEn = await leetCodeExecutor.listProblems(true,false);
const reg: RegExp = /^(.)\s(.{1,2})\s(.)\s\[\s*(\d*)\s*\]\s*(.*)\s*(Easy|Medium|Hard)\s*\((\s*\d+\.\d+ %)\)/;
let classic150Problems = [
88,
27,
26,
80,
169,
189,
121,
122,
55,
45,
274,
380,
238,
134,
135,
42,
13,
12,
58,
14,
151,
6,
28,
68,
125,
392,
167,
11,
15,
209,
3,
30,
76,
36,
54,
48,
73,
289,
383,
205,
290,
242,
49,
1,
202,
219,
128,
228,
56,
57,
452,
20,
71,
155,
150,
224,
141,
2,
21,
138,
92,
25,
19,
82,
61,
86,
146,
104,
100,
226,
101,
105,
106,
117,
114,
112,
129,
124,
173,
222,
236,
199,
637,
102,
103,
530,
230,
98,
200,
130,
133,
399,
207,
210,
945,
433,
127,
208,
211,
212,
17,
77,
46,
39,
52,
22,
79,
108,
148,
772,
23,
53,
954,
35,
74,
162,
33,
34,
153,
4,
215,
502,
373,
295,
67,
190,
191,
136,
137,
201,
9,
66,
172,
69,
50,
149,
70,
198,
139,
322,
300,
120,
64,
63,
5,
97,
72,
123,
188,
221
];
let hot100Problems = [
1,
49,
128,
283,
11,
15,
42,
3,
438,
560,
239,
76,
53,
56,
189,
238,
41,
73,
54,
48,
240,
160,
206,
234,
141,
142,
21,
2,
19,
24,
25,
138,
148,
23,
146,
94,
104,
226,
101,
543,
102,
108,
98,
230,
199,
114,
105,
437,
236,
124,
200,
1036,
207,
208,
46,
78,
17,
39,
22,
79,
131,
51,
35,
74,
34,
33,
153,
4,
20,
155,
394,
739,
84,
215,
347,
295,
121,
55,
45,
768,
70,
118,
198,
279,
322,
139,
300,
152,
416,
32,
62,
64,
5,
1250,
72,
136,
169,
75,
31,
287
]
const problems: IProblem[] = [];
const linesEn: string[] = resultEn.split("\n");
const enNameMap: { [key: string]: string } = {};
for (const lineEn of linesEn) {
const matchEn: RegExpMatchArray | null = lineEn.match(reg);
if (matchEn && matchEn.length === 8) {
const idEn: string = matchEn[4].trim();
enNameMap[idEn] = matchEn[5].trim();
}
}
const lines: string[] = result.split("\n");
const reg: RegExp = /^(.)\s(.{1,2})\s(.)\s\[\s*(\d*)\s*\]\s*(.*)\s*(Easy|Medium|Hard)\s*\((\s*\d+\.\d+ %)\)/;

const { companies, tags } = await leetCodeExecutor.getCompaniesAndTags();
for (const line of lines) {
const match: RegExpMatchArray | null = line.match(reg);
@@ -28,7 +294,10 @@ export async function listProblems(): Promise<IProblem[]> {
isFavorite: match[1].trim().length > 0,
locked: match[2].trim().length > 0,
state: parseProblemState(match[3]),
isHot100: hot100Problems.includes(Number(id)),
isClassic150: classic150Problems.includes(Number(id)),
name: match[5].trim(),
nameEn: enNameMap[id] ,
difficulty: match[6].trim(),
passRate: match[7].trim(),
companies: companies[id] || ["Unknown"],
6 changes: 3 additions & 3 deletions src/commands/show.ts
Original file line number Diff line number Diff line change
@@ -263,12 +263,12 @@ async function resolveRelativePath(relativePath: string, node: IProblem, selecte
case "name":
return node.name;
case "camelcasename":
return _.camelCase(node.name);
return _.camelCase(node.nameEn);
case "pascalcasename":
return _.upperFirst(_.camelCase(node.name));
return _.upperFirst(_.camelCase(node.nameEn));
case "kebabcasename":
case "kebab-case-name":
return _.kebabCase(node.name);
return _.kebabCase(node.nameEn);
case "snakecasename":
case "snake_case_name":
return _.snakeCase(node.name);
9 changes: 9 additions & 0 deletions src/explorer/LeetCodeNode.ts
Original file line number Diff line number Diff line change
@@ -34,6 +34,9 @@ export class LeetCodeNode {
public get tags(): string[] {
return this.data.tags;
}
public get nameEn(): string {
return this.data.nameEn;
}

public get companies(): string[] {
return this.data.companies;
@@ -42,6 +45,12 @@ export class LeetCodeNode {
public get isFavorite(): boolean {
return this.data.isFavorite;
}
public get isHot100(): boolean {
return this.data.isHot100;
}
public get isClassic150(): boolean {
return this.data.isClassic150;
}

public get isProblem(): boolean {
return this.isProblemNode;
4 changes: 4 additions & 0 deletions src/explorer/LeetCodeTreeDataProvider.ts
Original file line number Diff line number Diff line change
@@ -85,6 +85,10 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod
return explorerNodeManager.getAllTagNodes();
case Category.Company:
return explorerNodeManager.getAllCompanyNodes();
case Category.Hot100:
return explorerNodeManager.getHot100Nodes();
case Category.InterviewClassics150Problems:
return explorerNodeManager.getInterviewClassics150Nodes();
default:
if (element.isProblem) {
return [];
Loading