Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# version 2.19.14

- 在 ID 含有空格的题目对应的文件中,点击 Description 按钮时,无法识别题目 ID

## version 2.19.13

- 增加重试上次测试用例按钮 retest
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"name": "vscode-leetcode-problem-rating",
"displayName": "LeetCode",
"description": "%main.description%",
"version": "2.19.13",
"version": "2.19.14",
"author": "ccagml",
"publisher": "ccagml",
"license": "MIT",
13 changes: 6 additions & 7 deletions src/utils/SystemUtils.ts
Original file line number Diff line number Diff line change
@@ -7,13 +7,14 @@
* Copyright (c) 2022 ccagml . All rights reserved.
*/

import * as fse from "fs-extra";
import * as fs from "fs";
import * as _ from "lodash";
import * as path from "path";
import { IProblem, langExt } from "../model/Model";
import { executeCommand } from "./CliUtils";
import { isUseVscodeNode, isUseWsl } from "./ConfigUtils";
import { Uri, window, TextEditor } from "vscode";
import { fileMeta, ProblemMeta } from "../utils/problemUtils";

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

export async function getNodeIdFromFile(fsPath: string): Promise<string> {
const fileContent: string = await fse.readFile(fsPath, "utf8");
let id: string = "";
const matchResults: RegExpMatchArray | null = fileContent.match(/@lc.+id=(.+?) /);
if (matchResults && matchResults.length === 2) {
id = matchResults[1];
}
const fileContent: Buffer = fs.readFileSync(fsPath);
const meta: ProblemMeta | null = fileMeta(fileContent.toString());

let id = meta?.id;
// Try to get id from file name if getting from comments failed
if (!id) {
id = path.basename(fsPath).split(".")[0];