Skip to content

Commit

Permalink
Fix Rope.starts_with. (helix-editor#11739)
Browse files Browse the repository at this point in the history
Co-authored-by: Rose Hogenson <rosehogenson@posteo.net>
  • Loading branch information
rhogenson and Rose Hogenson authored Sep 21, 2024
1 parent 9f93de5 commit 5717aa8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion helix-stdx/src/rope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'a> RopeSliceExt<'a> for RopeSlice<'a> {
if len < text.len() {
return false;
}
self.get_byte_slice(..len - text.len())
self.get_byte_slice(..text.len())
.map_or(false, |start| start == text)
}

Expand Down Expand Up @@ -137,4 +137,14 @@ mod tests {
}
}
}

#[test]
fn starts_with() {
assert!(RopeSlice::from("asdf").starts_with("a"));
}

#[test]
fn ends_with() {
assert!(RopeSlice::from("asdf").ends_with("f"));
}
}

0 comments on commit 5717aa8

Please sign in to comment.