first pass of merging in warp (doesn't build)

This commit is contained in:
Ryan Ward
2026-07-01 16:08:58 -05:00
parent 2f64909469
commit 4770ac06b5
3662 changed files with 414574 additions and 89772 deletions
@@ -0,0 +1,49 @@
use std::path::PathBuf;
use string_offset::ByteOffset;
use warp_ripgrep::search::{Match as RipgrepMatch, Submatch};
use super::ripgrep_match_to_proto;
fn submatch(start: usize, end: usize) -> Submatch {
Submatch {
byte_start: ByteOffset::from(start),
byte_end: ByteOffset::from(end),
}
}
#[test]
fn ripgrep_match_to_proto_maps_fields() {
let m = RipgrepMatch {
file_path: PathBuf::from("/repo/src/main.rs"),
line_number: 42,
line_text: "fn main() {}".to_string(),
submatches: vec![submatch(3, 7)],
};
let proto = ripgrep_match_to_proto(m);
assert_eq!(proto.file_path, "/repo/src/main.rs");
assert_eq!(proto.line_number, 42);
assert_eq!(proto.line_text, "fn main() {}");
assert_eq!(proto.submatches.len(), 1);
assert_eq!(proto.submatches[0].byte_start, 3);
assert_eq!(proto.submatches[0].byte_end, 7);
}
#[test]
fn ripgrep_match_to_proto_preserves_late_submatch_and_full_line() {
let line = format!("{}needle", "x".repeat(8_000));
let m = RipgrepMatch {
file_path: PathBuf::from("/repo/long.rs"),
line_number: 1,
line_text: line.clone(),
submatches: vec![submatch(8_000, 8_006)],
};
let proto = ripgrep_match_to_proto(m);
assert_eq!(proto.line_text, line);
assert_eq!(proto.submatches[0].byte_start, 8_000);
assert_eq!(proto.submatches[0].byte_end, 8_006);
}