Skip to content

修复某些情况下, allcase 没解析成功,如 1040 题 #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
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.3

- 修复某些情况下, allcase 没解析成功,如 1040 题

## version 2.19.2

- 修复某些情况下调用 allcase 报错,如 1017 题
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-leetcode-problem-rating",
"displayName": "LeetCode",
"description": "%main.description%",
"version": "2.19.2",
"version": "2.19.3",
"author": "ccagml",
"publisher": "ccagml",
"license": "MIT",
Expand Down
64 changes: 35 additions & 29 deletions src/rpc/utils/storageUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,28 +342,26 @@ class StorageUtils {
let temp_collect = "";
for (let all_input = 0; all_input < input.length; all_input++) {
const element = input[all_input];
let check_index = element.indexOf("输入:");

if (check_index == -1) {
check_index = element.indexOf("输入:");
}
let check_input_1 = element.indexOf("输入:");
let check_input_2 = element.indexOf("输入:");
let check_input_3 = element.indexOf("Input:");
if (check_input_1 != -1 || check_input_2 != -1 || check_input_3 != -1) {
if (check_input_1 != -1) {
temp_collect += element.substring(check_input_1 + 3);
} else if (check_input_2 != -1) {
temp_collect += element.substring(check_input_2 + 3);
} else if (check_input_3 != -1) {
temp_collect += element.substring(check_input_3 + 6);
}

if (check_index == -1) {
check_index = element.indexOf("Input:");
}
if (check_index != -1) {
temp_collect += element.substring(check_index + 1);
start_flag = true;
continue;
}
check_index = element.indexOf("输出:");
if (check_index == -1) {
check_index = element.indexOf("输出:");
}
if (check_index == -1) {
check_index = element.indexOf("Output:");
}
if (check_index != -1) {

let check_index_1 = element.indexOf("输出:");
let check_index_2 = element.indexOf("输出:");
let check_index_3 = element.indexOf("Output:");
if (check_index_1 != -1 || check_index_2 != -1 || check_index_3 != -1) {
start_flag = false;
}
if (start_flag) {
Expand All @@ -374,21 +372,29 @@ class StorageUtils {
let temp_case: Array<any> = [];
let wait_cur = "";
let no_need_flag = false;
for (let index = new_ele.length - 1; index >= 0; index--) {
if (no_need_flag) {
if (new_ele[index] == ",") {
no_need_flag = false;
}
} else {
if (new_ele[index] == "=") {
temp_case.push(wait_cur.trim());
no_need_flag = true;
wait_cur = "";

// 1040题的输入不标准 没有 x = aaa
if (temp_collect.indexOf("=") == -1) {
temp_case.push(temp_collect.trim());
} else {
// 解析 x = aaa, y = bbb 之类的输入参数
for (let index = new_ele.length - 1; index >= 0; index--) {
if (no_need_flag) {
if (new_ele[index] == ",") {
no_need_flag = false;
}
} else {
wait_cur = new_ele[index] + wait_cur;
if (new_ele[index] == "=") {
temp_case.push(wait_cur.trim());
no_need_flag = true;
wait_cur = "";
} else {
wait_cur = new_ele[index] + wait_cur;
}
}
}
}

let new_temp_case: Array<any> = [];
for (let tci = temp_case.length - 1; tci >= 0; tci--) {
new_temp_case.push(temp_case[tci]);
Expand Down