Skip to content
Open
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
23 changes: 23 additions & 0 deletions crates/fff-core/src/simd_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,29 @@ mod tests {
assert_eq!(std::str::from_utf8(&reconstructed).unwrap(), path);
}

#[test]
fn test_relative_path_eq_path_exceeding_512_bytes() {
let mut path = String::new();
while path.len() < 600 {
path.push_str("deeply_nested_directory_segment/");
}
path.push_str("needle_file.rs");
assert!(path.len() > 512 && path.len() < PATH_BUF_SIZE);

let (store, _strings, files) = build_test_store(&[path.as_str(), "src/lib.rs"]);
let arena = store.as_arena_ptr();

assert!(
files[0].relative_path_eq(arena, &path),
"a PATH_MAX-legal path must compare equal to itself"
);

// Short paths keep comparing exactly as before.
assert!(files[1].relative_path_eq(arena, "src/lib.rs"));
assert!(!files[1].relative_path_eq(arena, "src/main.rs"));
assert!(!files[0].relative_path_eq(arena, &path[..path.len() - 1]));
}

#[test]
fn test_filename_cow_mid_chunk() {
let (store, strings, _files) = build_test_store(&["src/components/Button.tsx"]);
Expand Down
2 changes: 1 addition & 1 deletion crates/fff-core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ impl FileItem {
if other.len() != self.path.byte_len as usize {
return false;
}
let mut buf = [0u8; 512];
let mut buf = [0u8; PATH_BUF_SIZE];
let mine = self.path.read_to_buf(arena, &mut buf);
mine == other
}
Expand Down