Skip to content

Commit 2907a5e

Browse files
committed
Description 无法识别某些题目
1 parent 3e20f9c commit 2907a5e

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# version 2.19.14
2+
3+
- 在 ID 含有空格的题目对应的文件中,点击 Description 按钮时,无法识别题目 ID
4+
15
## version 2.19.13
26

37
- 增加重试上次测试用例按钮 retest

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-leetcode-problem-rating",
33
"displayName": "LeetCode",
44
"description": "%main.description%",
5-
"version": "2.19.13",
5+
"version": "2.19.14",
66
"author": "ccagml",
77
"publisher": "ccagml",
88
"license": "MIT",

src/utils/SystemUtils.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
* Copyright (c) 2022 ccagml . All rights reserved.
88
*/
99

10-
import * as fse from "fs-extra";
10+
import * as fs from "fs";
1111
import * as _ from "lodash";
1212
import * as path from "path";
1313
import { IProblem, langExt } from "../model/Model";
1414
import { executeCommand } from "./CliUtils";
1515
import { isUseVscodeNode, isUseWsl } from "./ConfigUtils";
1616
import { Uri, window, TextEditor } from "vscode";
17+
import { fileMeta, ProblemMeta } from "../utils/problemUtils";
1718

1819
export function isWindows(): boolean {
1920
return process.platform === "win32";
@@ -58,12 +59,10 @@ export function genFileName(node: IProblem, language: string): string {
5859
}
5960

6061
export async function getNodeIdFromFile(fsPath: string): Promise<string> {
61-
const fileContent: string = await fse.readFile(fsPath, "utf8");
62-
let id: string = "";
63-
const matchResults: RegExpMatchArray | null = fileContent.match(/@lc.+id=(.+?) /);
64-
if (matchResults && matchResults.length === 2) {
65-
id = matchResults[1];
66-
}
62+
const fileContent: Buffer = fs.readFileSync(fsPath);
63+
const meta: ProblemMeta | null = fileMeta(fileContent.toString());
64+
65+
let id = meta?.id;
6766
// Try to get id from file name if getting from comments failed
6867
if (!id) {
6968
id = path.basename(fsPath).split(".")[0];

0 commit comments

Comments
 (0)