refactor(desktop): classify added line checks in one pass (#17324)

This commit is contained in:
Vincent Koc
2026-12-06 08:38:02 +08:00
committed by GitHub
parent a14c07f96c
commit 9f712309da
+8 -10
View File
@@ -212,18 +212,16 @@ export const addedLineChecks = (
}
lineStart = lineEnd + 1;
}
const classified = added
.filter((line) => !unexamined.has(line))
.map((line) => ({
line,
at: classifications.get(line) ?? -1,
}));
const whole = classified.filter(({ at }) => at < 0).map(({ line }) => line);
const whole: string[] = [];
const prefixes = new Set<string>();
let unnamed = 0;
for (const { line, at } of classified.filter(
({ at }) => counted && at >= 0,
)) {
for (const line of added.filter((value) => !unexamined.has(value))) {
const at = classifications.get(line) ?? -1;
if (at < 0) {
whole.push(line);
continue;
}
if (!counted) continue;
const prefix = line.slice(0, at).trimStart();
const equals = holding(lines.after, prefix);
if (