chore: reformat

This commit is contained in:
can1357
2026-04-24 07:18:17 +02:00
parent daa3f6237d
commit f5e69ea37f
3 changed files with 13 additions and 30 deletions
+8 -10
View File
@@ -266,7 +266,11 @@ fn translate_msys_segment(segment: &str, install_roots: &[PathBuf]) -> Option<St
}
fn is_drive_letter(value: &str) -> bool {
value.len() == 1 && value.chars().next().is_some_and(|c| c.is_ascii_alphabetic())
value.len() == 1
&& value
.chars()
.next()
.is_some_and(|c| c.is_ascii_alphabetic())
}
fn is_windows_style_path(value: &str) -> bool {
@@ -283,14 +287,8 @@ mod tests {
#[test]
fn drive_letter_segments_translate_to_windows_paths() {
assert_eq!(
translate_msys_segment("/c/Users/foo", &[]).as_deref(),
Some("C:\\Users\\foo"),
);
assert_eq!(
translate_msys_segment("/d", &[]).as_deref(),
Some("D:\\"),
);
assert_eq!(translate_msys_segment("/c/Users/foo", &[]).as_deref(), Some("C:\\Users\\foo"),);
assert_eq!(translate_msys_segment("/d", &[]).as_deref(), Some("D:\\"),);
}
#[test]
@@ -308,4 +306,4 @@ mod tests {
assert!(!is_drive_letter("cc"));
assert!(!is_drive_letter("1"));
}
}
}
@@ -96,7 +96,7 @@ function stripLeadingHashlinePrefixes(line: string): string {
return result;
}
function filterTruncationNotices(lines: string[]): string[] {
function _filterTruncationNotices(lines: string[]): string[] {
return lines.filter(line => !READ_TRUNCATION_NOTICE_RE.test(line));
}
@@ -126,9 +126,7 @@ export function stripHashlinePrefixes(lines: string[]): string[] {
const { nonEmpty, hashPrefixCount } = collectLinePrefixStats(lines);
if (nonEmpty === 0) return lines;
if (hashPrefixCount !== nonEmpty) return lines;
return lines
.filter(line => !READ_TRUNCATION_NOTICE_RE.test(line))
.map(line => stripLeadingHashlinePrefixes(line));
return lines.filter(line => !READ_TRUNCATION_NOTICE_RE.test(line)).map(line => stripLeadingHashlinePrefixes(line));
}
const linesSchema = Type.Union([
@@ -959,23 +959,14 @@ describe("stripNewLinePrefixes", () => {
});
it("strips hashline prefixes when generic read truncation notice is present", () => {
const lines = [
"1#BQ:line one",
"2#XS:line two",
"",
"[42 more lines in file. Use sel=L3 to continue]",
];
const lines = ["1#BQ:line one", "2#XS:line two", "", "[42 more lines in file. Use sel=L3 to continue]"];
const result = stripNewLinePrefixes(lines);
expect(result[0]).toBe("line one");
expect(result[1]).toBe("line two");
});
it("strips nested hashline prefixes (already-corrupted content re-read)", () => {
const lines = [
"1#NX:1#BQ:---",
"2#TY:2#XS:title: example",
"3#JZ:3#BQ:---",
];
const lines = ["1#NX:1#BQ:---", "2#TY:2#XS:title: example", "3#JZ:3#BQ:---"];
const result = stripNewLinePrefixes(lines);
expect(result[0]).toBe("---");
expect(result[1]).toBe("title: example");
@@ -1013,15 +1004,11 @@ describe("stripHashlinePrefixes", () => {
});
it("strips nested hashline prefixes from already-corrupted content", () => {
const lines = [
"1#NX:1#BQ:---",
"2#TY:2#XS:title",
];
const lines = ["1#NX:1#BQ:---", "2#TY:2#XS:title"];
const result = stripHashlinePrefixes(lines);
expect(result[0]).toBe("---");
expect(result[1]).toBe("title");
});
});
// ═══════════════════════════════════════════════════════════════════════════