mirror of https://github.com/helix-editor/helix
Merge d7dd43815a
into 205e7ece70
commit
2ffdb2e2d2
|
@ -1170,6 +1170,68 @@ mod test {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_select_on_matches_crlf() {
|
||||||
|
let r = Rope::from_str("This\r\nString\r\n\r\ncontains multiple\r\nlines");
|
||||||
|
let s = r.slice(..);
|
||||||
|
|
||||||
|
let start_of_line = rope::RegexBuilder::new()
|
||||||
|
.syntax(rope::Config::new().multi_line(true).crlf(true))
|
||||||
|
.build(r"^")
|
||||||
|
.unwrap();
|
||||||
|
let end_of_line = rope::RegexBuilder::new()
|
||||||
|
.syntax(rope::Config::new().multi_line(true).crlf(true))
|
||||||
|
.build(r"$")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// line without ending
|
||||||
|
assert_eq!(
|
||||||
|
select_on_matches(s, &Selection::single(0, 4), &start_of_line),
|
||||||
|
Some(Selection::single(0, 0))
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
select_on_matches(s, &Selection::single(0, 4), &end_of_line),
|
||||||
|
None
|
||||||
|
);
|
||||||
|
// line with ending
|
||||||
|
assert_eq!(
|
||||||
|
select_on_matches(s, &Selection::single(0, 5), &start_of_line),
|
||||||
|
Some(Selection::single(0, 0))
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
select_on_matches(s, &Selection::single(0, 5), &end_of_line),
|
||||||
|
Some(Selection::single(4, 4))
|
||||||
|
);
|
||||||
|
// line with start of next line
|
||||||
|
assert_eq!(
|
||||||
|
select_on_matches(s, &Selection::single(0, 7), &start_of_line),
|
||||||
|
Some(Selection::new(
|
||||||
|
smallvec![Range::point(0), Range::point(6)],
|
||||||
|
0
|
||||||
|
))
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
select_on_matches(s, &Selection::single(0, 6), &end_of_line),
|
||||||
|
Some(Selection::single(4, 4))
|
||||||
|
);
|
||||||
|
|
||||||
|
// multiple lines
|
||||||
|
assert_eq!(
|
||||||
|
select_on_matches(
|
||||||
|
s,
|
||||||
|
&Selection::single(0, s.len_chars()),
|
||||||
|
&rope::RegexBuilder::new()
|
||||||
|
.syntax(rope::Config::new().multi_line(true).crlf(true))
|
||||||
|
.build(r"^[a-z ]*$")
|
||||||
|
.unwrap()
|
||||||
|
),
|
||||||
|
Some(Selection::new(
|
||||||
|
smallvec![Range::point(14), Range::new(16, 33), Range::new(35, 40)],
|
||||||
|
0
|
||||||
|
))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_line_range() {
|
fn test_line_range() {
|
||||||
let r = Rope::from_str("\r\nHi\r\nthere!");
|
let r = Rope::from_str("\r\nHi\r\nthere!");
|
||||||
|
|
|
@ -2292,7 +2292,8 @@ fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Dir
|
||||||
.syntax(
|
.syntax(
|
||||||
rope::Config::new()
|
rope::Config::new()
|
||||||
.case_insensitive(case_insensitive)
|
.case_insensitive(case_insensitive)
|
||||||
.multi_line(true),
|
.multi_line(true)
|
||||||
|
.crlf(true),
|
||||||
)
|
)
|
||||||
.build(&query)
|
.build(&query)
|
||||||
{
|
{
|
||||||
|
|
|
@ -127,7 +127,8 @@ pub fn raw_regex_prompt(
|
||||||
.syntax(
|
.syntax(
|
||||||
rope::Config::new()
|
rope::Config::new()
|
||||||
.case_insensitive(case_insensitive)
|
.case_insensitive(case_insensitive)
|
||||||
.multi_line(true),
|
.multi_line(true)
|
||||||
|
.crlf(true),
|
||||||
)
|
)
|
||||||
.build(input)
|
.build(input)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue