Use character offsets in diff.
This commit is contained in:
@@ -115,12 +115,13 @@ impl<'s> DiffResult<'s> {
|
||||
}
|
||||
};
|
||||
let rust_offset = self.rust_source.as_ptr() as usize - original_document.as_ptr() as usize;
|
||||
let preceding_text = &original_document[..rust_offset];
|
||||
println!(
|
||||
"{indentation}{status_text} {name} char({char_offset}) {message}",
|
||||
indentation = " ".repeat(indentation),
|
||||
status_text = status_text,
|
||||
name = self.name,
|
||||
char_offset = rust_offset + 1,
|
||||
char_offset = preceding_text.chars().count() + 1,
|
||||
message = self.message.as_ref().map(|m| m.as_str()).unwrap_or("")
|
||||
);
|
||||
for child in self.children.iter() {
|
||||
|
||||
@@ -51,7 +51,7 @@ pub fn assert_bounds<'s, S: Source<'s>>(
|
||||
);
|
||||
let (rust_begin, rust_end) = get_offsets(source, rust);
|
||||
if (rust_begin + 1) != begin || (rust_end + 1) != end {
|
||||
Err(format!("Rust bounds ({rust_begin}, {rust_end}) do not match emacs bounds ({emacs_begin}, {emacs_end})", rust_begin = rust_begin + 1, rust_end = rust_end + 1, emacs_begin=begin, emacs_end=end))?;
|
||||
Err(format!("Rust bounds (in bytes) ({rust_begin}, {rust_end}) do not match emacs bounds ({emacs_begin}, {emacs_end})", rust_begin = rust_begin + 1, rust_end = rust_end + 1, emacs_begin=begin, emacs_end=end))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user