on master help sign in
Apply recent nightly suggestions (#1286)
02fc52fKirawi
helix-core/src/movement.rs+25−27
@@ -307,8 +307,6 @@ fn reached_target(target: WordMotionTarget, prev_ch: char, next_ch: char) -> boo
307
307
308#[cfg(test)]
308#[cfg(test)]
309mod test {
309mod test {
310− use std::array::{self, IntoIter};
311−
312 use ropey::Rope;
310 use ropey::Rope;
313
311
314 use super::*;
312 use super::*;
@@ -360,7 +358,7 @@ mod test {
360 ((Direction::Backward, 999usize), (0, 0)), // |This is a simple alphabetic line
358 ((Direction::Backward, 999usize), (0, 0)), // |This is a simple alphabetic line
361 ];
359 ];
362
360
363− for ((direction, amount), coordinates) in IntoIter::new(moves_and_expected_coordinates) {
361+ for ((direction, amount), coordinates) in moves_and_expected_coordinates {
364 range = move_horizontally(slice, range, direction, amount, Movement::Move);
362 range = move_horizontally(slice, range, direction, amount, Movement::Move);
365 assert_eq!(coords_at_pos(slice, range.head), coordinates.into())
363 assert_eq!(coords_at_pos(slice, range.head), coordinates.into())
366 }
364 }
@@ -374,7 +372,7 @@ mod test {
374
372
375 let mut range = Range::point(position);
373 let mut range = Range::point(position);
376
374
377− let moves_and_expected_coordinates = IntoIter::new([
375+ let moves_and_expected_coordinates = [
378 ((Direction::Forward, 11usize), (1, 1)), // Multiline\nt|ext sample\n...
376 ((Direction::Forward, 11usize), (1, 1)), // Multiline\nt|ext sample\n...
379 ((Direction::Backward, 1usize), (1, 0)), // Multiline\n|text sample\n...
377 ((Direction::Backward, 1usize), (1, 0)), // Multiline\n|text sample\n...
380 ((Direction::Backward, 5usize), (0, 5)), // Multi|line\ntext sample\n...
378 ((Direction::Backward, 5usize), (0, 5)), // Multi|line\ntext sample\n...
@@ -384,7 +382,7 @@ mod test {
384 ((Direction::Backward, 0usize), (0, 3)), // Mul|tiline\ntext sample\n...
382 ((Direction::Backward, 0usize), (0, 3)), // Mul|tiline\ntext sample\n...
385 ((Direction::Forward, 999usize), (5, 0)), // ...and whitespaced\n|
383 ((Direction::Forward, 999usize), (5, 0)), // ...and whitespaced\n|
386 ((Direction::Forward, 999usize), (5, 0)), // ...and whitespaced\n|
384 ((Direction::Forward, 999usize), (5, 0)), // ...and whitespaced\n|
387− ]);
385+ ];
388
386
389 for ((direction, amount), coordinates) in moves_and_expected_coordinates {
387 for ((direction, amount), coordinates) in moves_and_expected_coordinates {
390 range = move_horizontally(slice, range, direction, amount, Movement::Move);
388 range = move_horizontally(slice, range, direction, amount, Movement::Move);
@@ -402,11 +400,11 @@ mod test {
402 let mut range = Range::point(position);
400 let mut range = Range::point(position);
403 let original_anchor = range.anchor;
401 let original_anchor = range.anchor;
404
402
405− let moves = IntoIter::new([
403+ let moves = [
406 (Direction::Forward, 1usize),
404 (Direction::Forward, 1usize),
407 (Direction::Forward, 5usize),
405 (Direction::Forward, 5usize),
408 (Direction::Backward, 3usize),
406 (Direction::Backward, 3usize),
409− ]);
407+ ];
410
408
411 for (direction, amount) in moves {
409 for (direction, amount) in moves {
412 range = move_horizontally(slice, range, direction, amount, Movement::Extend);
410 range = move_horizontally(slice, range, direction, amount, Movement::Extend);
@@ -420,7 +418,7 @@ mod test {
420 let slice = text.slice(..);
418 let slice = text.slice(..);
421 let position = pos_at_coords(slice, (0, 0).into(), true);
419 let position = pos_at_coords(slice, (0, 0).into(), true);
422 let mut range = Range::point(position);
420 let mut range = Range::point(position);
423− let moves_and_expected_coordinates = IntoIter::new([
421+ let moves_and_expected_coordinates = [
424 ((Direction::Forward, 1usize), (1, 0)),
422 ((Direction::Forward, 1usize), (1, 0)),
425 ((Direction::Forward, 2usize), (3, 0)),
423 ((Direction::Forward, 2usize), (3, 0)),
426 ((Direction::Forward, 1usize), (4, 0)),
424 ((Direction::Forward, 1usize), (4, 0)),
@@ -430,7 +428,7 @@ mod test {
430 ((Direction::Backward, 0usize), (4, 0)),
428 ((Direction::Backward, 0usize), (4, 0)),
431 ((Direction::Forward, 5), (5, 0)),
429 ((Direction::Forward, 5), (5, 0)),
432 ((Direction::Forward, 999usize), (5, 0)),
430 ((Direction::Forward, 999usize), (5, 0)),
433− ]);
431+ ];
434
432
435 for ((direction, amount), coordinates) in moves_and_expected_coordinates {
433 for ((direction, amount), coordinates) in moves_and_expected_coordinates {
436 range = move_vertically(slice, range, direction, amount, Movement::Move);
434 range = move_vertically(slice, range, direction, amount, Movement::Move);
@@ -450,7 +448,7 @@ mod test {
450 H,
448 H,
451 V,
449 V,
452 }
450 }
453− let moves_and_expected_coordinates = IntoIter::new([
451+ let moves_and_expected_coordinates = [
454 // Places cursor at the end of line
452 // Places cursor at the end of line
455 ((Axis::H, Direction::Forward, 8usize), (0, 8)),
453 ((Axis::H, Direction::Forward, 8usize), (0, 8)),
456 // First descent preserves column as the target line is wider
454 // First descent preserves column as the target line is wider
@@ -463,7 +461,7 @@ mod test {
463 ((Axis::V, Direction::Backward, 999usize), (0, 8)),
461 ((Axis::V, Direction::Backward, 999usize), (0, 8)),
464 ((Axis::V, Direction::Forward, 4usize), (4, 8)),
462 ((Axis::V, Direction::Forward, 4usize), (4, 8)),
465 ((Axis::V, Direction::Forward, 999usize), (5, 0)),
463 ((Axis::V, Direction::Forward, 999usize), (5, 0)),
466− ]);
464+ ];
467
465
468 for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
466 for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
469 range = match axis {
467 range = match axis {
@@ -489,7 +487,7 @@ mod test {
489 H,
487 H,
490 V,
488 V,
491 }
489 }
492− let moves_and_expected_coordinates = IntoIter::new([
490+ let moves_and_expected_coordinates = [
493 // Places cursor at the fourth kana.
491 // Places cursor at the fourth kana.
494 ((Axis::H, Direction::Forward, 4), (0, 4)),
492 ((Axis::H, Direction::Forward, 4), (0, 4)),
495 // Descent places cursor at the 4th character.
493 // Descent places cursor at the 4th character.
@@ -498,7 +496,7 @@ mod test {
498 ((Axis::H, Direction::Backward, 1usize), (1, 3)),
496 ((Axis::H, Direction::Backward, 1usize), (1, 3)),
499 // Jumping back up 1 line.
497 // Jumping back up 1 line.
500 ((Axis::V, Direction::Backward, 1usize), (0, 3)),
498 ((Axis::V, Direction::Backward, 1usize), (0, 3)),
501− ]);
499+ ];
502
500
503 for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
501 for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
504 range = match axis {
502 range = match axis {
@@ -530,7 +528,7 @@ mod test {
530
528
531 #[test]
529 #[test]
532 fn test_behaviour_when_moving_to_start_of_next_words() {
530 fn test_behaviour_when_moving_to_start_of_next_words() {
533− let tests = array::IntoIter::new([
531+ let tests = [
534 ("Basic forward motion stops at the first space",
532 ("Basic forward motion stops at the first space",
535 vec![(1, Range::new(0, 0), Range::new(0, 6))]),
533 vec![(1, Range::new(0, 0), Range::new(0, 6))]),
536 (" Starting from a boundary advances the anchor",
534 (" Starting from a boundary advances the anchor",
@@ -604,7 +602,7 @@ mod test {
604 vec![
602 vec![
605 (1, Range::new(0, 0), Range::new(0, 6)),
603 (1, Range::new(0, 0), Range::new(0, 6)),
606 ]),
604 ]),
607− ]);
605+ ];
608
606
609 for (sample, scenario) in tests {
607 for (sample, scenario) in tests {
610 for (count, begin, expected_end) in scenario.into_iter() {
608 for (count, begin, expected_end) in scenario.into_iter() {
@@ -616,7 +614,7 @@ mod test {
616
614
617 #[test]
615 #[test]
618 fn test_behaviour_when_moving_to_start_of_next_long_words() {
616 fn test_behaviour_when_moving_to_start_of_next_long_words() {
619− let tests = array::IntoIter::new([
617+ let tests = [
620 ("Basic forward motion stops at the first space",
618 ("Basic forward motion stops at the first space",
621 vec![(1, Range::new(0, 0), Range::new(0, 6))]),
619 vec![(1, Range::new(0, 0), Range::new(0, 6))]),
622 (" Starting from a boundary advances the anchor",
620 (" Starting from a boundary advances the anchor",
@@ -688,7 +686,7 @@ mod test {
688 vec![
686 vec![
689 (1, Range::new(0, 0), Range::new(0, 8)),
687 (1, Range::new(0, 0), Range::new(0, 8)),
690 ]),
688 ]),
691− ]);
689+ ];
692
690
693 for (sample, scenario) in tests {
691 for (sample, scenario) in tests {
694 for (count, begin, expected_end) in scenario.into_iter() {
692 for (count, begin, expected_end) in scenario.into_iter() {
@@ -700,7 +698,7 @@ mod test {
700
698
701 #[test]
699 #[test]
702 fn test_behaviour_when_moving_to_start_of_previous_words() {
700 fn test_behaviour_when_moving_to_start_of_previous_words() {
703− let tests = array::IntoIter::new([
701+ let tests = [
704 ("Basic backward motion from the middle of a word",
702 ("Basic backward motion from the middle of a word",
705 vec![(1, Range::new(3, 3), Range::new(4, 0))]),
703 vec![(1, Range::new(3, 3), Range::new(4, 0))]),
706
704
@@ -773,7 +771,7 @@ mod test {
773 vec![
771 vec![
774 (1, Range::new(0, 6), Range::new(6, 0)),
772 (1, Range::new(0, 6), Range::new(6, 0)),
775 ]),
773 ]),
776− ]);
774+ ];
777
775
778 for (sample, scenario) in tests {
776 for (sample, scenario) in tests {
779 for (count, begin, expected_end) in scenario.into_iter() {
777 for (count, begin, expected_end) in scenario.into_iter() {
@@ -785,7 +783,7 @@ mod test {
785
783
786 #[test]
784 #[test]
787 fn test_behaviour_when_moving_to_start_of_previous_long_words() {
785 fn test_behaviour_when_moving_to_start_of_previous_long_words() {
788− let tests = array::IntoIter::new([
786+ let tests = [
789 (
787 (
790 "Basic backward motion from the middle of a word",
788 "Basic backward motion from the middle of a word",
791 vec![(1, Range::new(3, 3), Range::new(4, 0))],
789 vec![(1, Range::new(3, 3), Range::new(4, 0))],
@@ -870,7 +868,7 @@ mod test {
870 vec![
868 vec![
871 (1, Range::new(0, 8), Range::new(8, 0)),
869 (1, Range::new(0, 8), Range::new(8, 0)),
872 ]),
870 ]),
873− ]);
871+ ];
874
872
875 for (sample, scenario) in tests {
873 for (sample, scenario) in tests {
876 for (count, begin, expected_end) in scenario.into_iter() {
874 for (count, begin, expected_end) in scenario.into_iter() {
@@ -882,7 +880,7 @@ mod test {
882
880
883 #[test]
881 #[test]
884 fn test_behaviour_when_moving_to_end_of_next_words() {
882 fn test_behaviour_when_moving_to_end_of_next_words() {
885− let tests = array::IntoIter::new([
883+ let tests = [
886 ("Basic forward motion from the start of a word to the end of it",
884 ("Basic forward motion from the start of a word to the end of it",
887 vec![(1, Range::new(0, 0), Range::new(0, 5))]),
885 vec![(1, Range::new(0, 0), Range::new(0, 5))]),
888 ("Basic forward motion from the end of a word to the end of the next",
886 ("Basic forward motion from the end of a word to the end of the next",
@@ -954,7 +952,7 @@ mod test {
954 vec![
952 vec![
955 (1, Range::new(0, 0), Range::new(0, 5)),
953 (1, Range::new(0, 0), Range::new(0, 5)),
956 ]),
954 ]),
957− ]);
955+ ];
958
956
959 for (sample, scenario) in tests {
957 for (sample, scenario) in tests {
960 for (count, begin, expected_end) in scenario.into_iter() {
958 for (count, begin, expected_end) in scenario.into_iter() {
@@ -966,7 +964,7 @@ mod test {
966
964
967 #[test]
965 #[test]
968 fn test_behaviour_when_moving_to_end_of_previous_words() {
966 fn test_behaviour_when_moving_to_end_of_previous_words() {
969− let tests = array::IntoIter::new([
967+ let tests = [
970 ("Basic backward motion from the middle of a word",
968 ("Basic backward motion from the middle of a word",
971 vec![(1, Range::new(9, 9), Range::new(10, 5))]),
969 vec![(1, Range::new(9, 9), Range::new(10, 5))]),
972 ("Starting from after boundary retreats the anchor",
970 ("Starting from after boundary retreats the anchor",
@@ -1036,7 +1034,7 @@ mod test {
1036 vec![
1034 vec![
1037 (1, Range::new(0, 10), Range::new(10, 4)),
1035 (1, Range::new(0, 10), Range::new(10, 4)),
1038 ]),
1036 ]),
1039− ]);
1037+ ];
1040
1038
1041 for (sample, scenario) in tests {
1039 for (sample, scenario) in tests {
1042 for (count, begin, expected_end) in scenario.into_iter() {
1040 for (count, begin, expected_end) in scenario.into_iter() {
@@ -1048,7 +1046,7 @@ mod test {
1048
1046
1049 #[test]
1047 #[test]
1050 fn test_behaviour_when_moving_to_end_of_next_long_words() {
1048 fn test_behaviour_when_moving_to_end_of_next_long_words() {
1051− let tests = array::IntoIter::new([
1049+ let tests = [
1052 ("Basic forward motion from the start of a word to the end of it",
1050 ("Basic forward motion from the start of a word to the end of it",
1053 vec![(1, Range::new(0, 0), Range::new(0, 5))]),
1051 vec![(1, Range::new(0, 0), Range::new(0, 5))]),
1054 ("Basic forward motion from the end of a word to the end of the next",
1052 ("Basic forward motion from the end of a word to the end of the next",
@@ -1118,7 +1116,7 @@ mod test {
1118 vec![
1116 vec![
1119 (1, Range::new(0, 0), Range::new(0, 7)),
1117 (1, Range::new(0, 0), Range::new(0, 7)),
1120 ]),
1118 ]),
1121− ]);
1119+ ];
1122
1120
1123 for (sample, scenario) in tests {
1121 for (sample, scenario) in tests {
1124 for (count, begin, expected_end) in scenario.into_iter() {
1122 for (count, begin, expected_end) in scenario.into_iter() {
helix-term/src/commands.rs+1−1
@@ -1938,7 +1938,7 @@ fn append_mode(cx: &mut Context) {
1938 if !last_range.is_empty() && last_range.head == end {
1938 if !last_range.is_empty() && last_range.head == end {
1939 let transaction = Transaction::change(
1939 let transaction = Transaction::change(
1940 doc.text(),
1940 doc.text(),
1941− std::array::IntoIter::new([(end, end, Some(doc.line_ending.as_str().into()))]),
1941+ [(end, end, Some(doc.line_ending.as_str().into()))].into_iter(),
1942 );
1942 );
1943 doc.apply(&transaction, view.id);
1943 doc.apply(&transaction, view.id);
1944 }
1944 }
helix-term/src/ui/prompt.rs+1−1
@@ -127,7 +127,7 @@ impl Prompt {
127 let mut char_position = char_indices
127 let mut char_position = char_indices
128 .iter()
128 .iter()
129 .position(|(idx, _)| *idx == self.cursor)
129 .position(|(idx, _)| *idx == self.cursor)
130− .unwrap_or_else(|| char_indices.len());
130+ .unwrap_or(char_indices.len());
131
131
132 for _ in 0..rep {
132 for _ in 0..rep {
133 // Skip any non-whitespace characters
133 // Skip any non-whitespace characters