Apply recent nightly suggestions (#1286)
array iterators are now implicit
This commit is contained in:
parent
a66833590c
commit
02fc52f6d5
3 changed files with 27 additions and 29 deletions
|
@ -307,8 +307,6 @@ fn reached_target(target: WordMotionTarget, prev_ch: char, next_ch: char) -> boo
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use std::array::{self, IntoIter};
|
|
||||||
|
|
||||||
use ropey::Rope;
|
use ropey::Rope;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -360,7 +358,7 @@ mod test {
|
||||||
((Direction::Backward, 999usize), (0, 0)), // |This is a simple alphabetic line
|
((Direction::Backward, 999usize), (0, 0)), // |This is a simple alphabetic line
|
||||||
];
|
];
|
||||||
|
|
||||||
for ((direction, amount), coordinates) in IntoIter::new(moves_and_expected_coordinates) {
|
for ((direction, amount), coordinates) in moves_and_expected_coordinates {
|
||||||
range = move_horizontally(slice, range, direction, amount, Movement::Move);
|
range = move_horizontally(slice, range, direction, amount, Movement::Move);
|
||||||
assert_eq!(coords_at_pos(slice, range.head), coordinates.into())
|
assert_eq!(coords_at_pos(slice, range.head), coordinates.into())
|
||||||
}
|
}
|
||||||
|
@ -374,7 +372,7 @@ mod test {
|
||||||
|
|
||||||
let mut range = Range::point(position);
|
let mut range = Range::point(position);
|
||||||
|
|
||||||
let moves_and_expected_coordinates = IntoIter::new([
|
let moves_and_expected_coordinates = [
|
||||||
((Direction::Forward, 11usize), (1, 1)), // Multiline\nt|ext sample\n...
|
((Direction::Forward, 11usize), (1, 1)), // Multiline\nt|ext sample\n...
|
||||||
((Direction::Backward, 1usize), (1, 0)), // Multiline\n|text sample\n...
|
((Direction::Backward, 1usize), (1, 0)), // Multiline\n|text sample\n...
|
||||||
((Direction::Backward, 5usize), (0, 5)), // Multi|line\ntext sample\n...
|
((Direction::Backward, 5usize), (0, 5)), // Multi|line\ntext sample\n...
|
||||||
|
@ -384,7 +382,7 @@ mod test {
|
||||||
((Direction::Backward, 0usize), (0, 3)), // Mul|tiline\ntext sample\n...
|
((Direction::Backward, 0usize), (0, 3)), // Mul|tiline\ntext sample\n...
|
||||||
((Direction::Forward, 999usize), (5, 0)), // ...and whitespaced\n|
|
((Direction::Forward, 999usize), (5, 0)), // ...and whitespaced\n|
|
||||||
((Direction::Forward, 999usize), (5, 0)), // ...and whitespaced\n|
|
((Direction::Forward, 999usize), (5, 0)), // ...and whitespaced\n|
|
||||||
]);
|
];
|
||||||
|
|
||||||
for ((direction, amount), coordinates) in moves_and_expected_coordinates {
|
for ((direction, amount), coordinates) in moves_and_expected_coordinates {
|
||||||
range = move_horizontally(slice, range, direction, amount, Movement::Move);
|
range = move_horizontally(slice, range, direction, amount, Movement::Move);
|
||||||
|
@ -402,11 +400,11 @@ mod test {
|
||||||
let mut range = Range::point(position);
|
let mut range = Range::point(position);
|
||||||
let original_anchor = range.anchor;
|
let original_anchor = range.anchor;
|
||||||
|
|
||||||
let moves = IntoIter::new([
|
let moves = [
|
||||||
(Direction::Forward, 1usize),
|
(Direction::Forward, 1usize),
|
||||||
(Direction::Forward, 5usize),
|
(Direction::Forward, 5usize),
|
||||||
(Direction::Backward, 3usize),
|
(Direction::Backward, 3usize),
|
||||||
]);
|
];
|
||||||
|
|
||||||
for (direction, amount) in moves {
|
for (direction, amount) in moves {
|
||||||
range = move_horizontally(slice, range, direction, amount, Movement::Extend);
|
range = move_horizontally(slice, range, direction, amount, Movement::Extend);
|
||||||
|
@ -420,7 +418,7 @@ mod test {
|
||||||
let slice = text.slice(..);
|
let slice = text.slice(..);
|
||||||
let position = pos_at_coords(slice, (0, 0).into(), true);
|
let position = pos_at_coords(slice, (0, 0).into(), true);
|
||||||
let mut range = Range::point(position);
|
let mut range = Range::point(position);
|
||||||
let moves_and_expected_coordinates = IntoIter::new([
|
let moves_and_expected_coordinates = [
|
||||||
((Direction::Forward, 1usize), (1, 0)),
|
((Direction::Forward, 1usize), (1, 0)),
|
||||||
((Direction::Forward, 2usize), (3, 0)),
|
((Direction::Forward, 2usize), (3, 0)),
|
||||||
((Direction::Forward, 1usize), (4, 0)),
|
((Direction::Forward, 1usize), (4, 0)),
|
||||||
|
@ -430,7 +428,7 @@ mod test {
|
||||||
((Direction::Backward, 0usize), (4, 0)),
|
((Direction::Backward, 0usize), (4, 0)),
|
||||||
((Direction::Forward, 5), (5, 0)),
|
((Direction::Forward, 5), (5, 0)),
|
||||||
((Direction::Forward, 999usize), (5, 0)),
|
((Direction::Forward, 999usize), (5, 0)),
|
||||||
]);
|
];
|
||||||
|
|
||||||
for ((direction, amount), coordinates) in moves_and_expected_coordinates {
|
for ((direction, amount), coordinates) in moves_and_expected_coordinates {
|
||||||
range = move_vertically(slice, range, direction, amount, Movement::Move);
|
range = move_vertically(slice, range, direction, amount, Movement::Move);
|
||||||
|
@ -450,7 +448,7 @@ mod test {
|
||||||
H,
|
H,
|
||||||
V,
|
V,
|
||||||
}
|
}
|
||||||
let moves_and_expected_coordinates = IntoIter::new([
|
let moves_and_expected_coordinates = [
|
||||||
// Places cursor at the end of line
|
// Places cursor at the end of line
|
||||||
((Axis::H, Direction::Forward, 8usize), (0, 8)),
|
((Axis::H, Direction::Forward, 8usize), (0, 8)),
|
||||||
// First descent preserves column as the target line is wider
|
// First descent preserves column as the target line is wider
|
||||||
|
@ -463,7 +461,7 @@ mod test {
|
||||||
((Axis::V, Direction::Backward, 999usize), (0, 8)),
|
((Axis::V, Direction::Backward, 999usize), (0, 8)),
|
||||||
((Axis::V, Direction::Forward, 4usize), (4, 8)),
|
((Axis::V, Direction::Forward, 4usize), (4, 8)),
|
||||||
((Axis::V, Direction::Forward, 999usize), (5, 0)),
|
((Axis::V, Direction::Forward, 999usize), (5, 0)),
|
||||||
]);
|
];
|
||||||
|
|
||||||
for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
|
for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
|
||||||
range = match axis {
|
range = match axis {
|
||||||
|
@ -489,7 +487,7 @@ mod test {
|
||||||
H,
|
H,
|
||||||
V,
|
V,
|
||||||
}
|
}
|
||||||
let moves_and_expected_coordinates = IntoIter::new([
|
let moves_and_expected_coordinates = [
|
||||||
// Places cursor at the fourth kana.
|
// Places cursor at the fourth kana.
|
||||||
((Axis::H, Direction::Forward, 4), (0, 4)),
|
((Axis::H, Direction::Forward, 4), (0, 4)),
|
||||||
// Descent places cursor at the 4th character.
|
// Descent places cursor at the 4th character.
|
||||||
|
@ -498,7 +496,7 @@ mod test {
|
||||||
((Axis::H, Direction::Backward, 1usize), (1, 3)),
|
((Axis::H, Direction::Backward, 1usize), (1, 3)),
|
||||||
// Jumping back up 1 line.
|
// Jumping back up 1 line.
|
||||||
((Axis::V, Direction::Backward, 1usize), (0, 3)),
|
((Axis::V, Direction::Backward, 1usize), (0, 3)),
|
||||||
]);
|
];
|
||||||
|
|
||||||
for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
|
for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
|
||||||
range = match axis {
|
range = match axis {
|
||||||
|
@ -530,7 +528,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_behaviour_when_moving_to_start_of_next_words() {
|
fn test_behaviour_when_moving_to_start_of_next_words() {
|
||||||
let tests = array::IntoIter::new([
|
let tests = [
|
||||||
("Basic forward motion stops at the first space",
|
("Basic forward motion stops at the first space",
|
||||||
vec![(1, Range::new(0, 0), Range::new(0, 6))]),
|
vec![(1, Range::new(0, 0), Range::new(0, 6))]),
|
||||||
(" Starting from a boundary advances the anchor",
|
(" Starting from a boundary advances the anchor",
|
||||||
|
@ -604,7 +602,7 @@ mod test {
|
||||||
vec![
|
vec![
|
||||||
(1, Range::new(0, 0), Range::new(0, 6)),
|
(1, Range::new(0, 0), Range::new(0, 6)),
|
||||||
]),
|
]),
|
||||||
]);
|
];
|
||||||
|
|
||||||
for (sample, scenario) in tests {
|
for (sample, scenario) in tests {
|
||||||
for (count, begin, expected_end) in scenario.into_iter() {
|
for (count, begin, expected_end) in scenario.into_iter() {
|
||||||
|
@ -616,7 +614,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_behaviour_when_moving_to_start_of_next_long_words() {
|
fn test_behaviour_when_moving_to_start_of_next_long_words() {
|
||||||
let tests = array::IntoIter::new([
|
let tests = [
|
||||||
("Basic forward motion stops at the first space",
|
("Basic forward motion stops at the first space",
|
||||||
vec![(1, Range::new(0, 0), Range::new(0, 6))]),
|
vec![(1, Range::new(0, 0), Range::new(0, 6))]),
|
||||||
(" Starting from a boundary advances the anchor",
|
(" Starting from a boundary advances the anchor",
|
||||||
|
@ -688,7 +686,7 @@ mod test {
|
||||||
vec![
|
vec![
|
||||||
(1, Range::new(0, 0), Range::new(0, 8)),
|
(1, Range::new(0, 0), Range::new(0, 8)),
|
||||||
]),
|
]),
|
||||||
]);
|
];
|
||||||
|
|
||||||
for (sample, scenario) in tests {
|
for (sample, scenario) in tests {
|
||||||
for (count, begin, expected_end) in scenario.into_iter() {
|
for (count, begin, expected_end) in scenario.into_iter() {
|
||||||
|
@ -700,7 +698,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_behaviour_when_moving_to_start_of_previous_words() {
|
fn test_behaviour_when_moving_to_start_of_previous_words() {
|
||||||
let tests = array::IntoIter::new([
|
let tests = [
|
||||||
("Basic backward motion from the middle of a word",
|
("Basic backward motion from the middle of a word",
|
||||||
vec![(1, Range::new(3, 3), Range::new(4, 0))]),
|
vec![(1, Range::new(3, 3), Range::new(4, 0))]),
|
||||||
|
|
||||||
|
@ -773,7 +771,7 @@ mod test {
|
||||||
vec![
|
vec![
|
||||||
(1, Range::new(0, 6), Range::new(6, 0)),
|
(1, Range::new(0, 6), Range::new(6, 0)),
|
||||||
]),
|
]),
|
||||||
]);
|
];
|
||||||
|
|
||||||
for (sample, scenario) in tests {
|
for (sample, scenario) in tests {
|
||||||
for (count, begin, expected_end) in scenario.into_iter() {
|
for (count, begin, expected_end) in scenario.into_iter() {
|
||||||
|
@ -785,7 +783,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_behaviour_when_moving_to_start_of_previous_long_words() {
|
fn test_behaviour_when_moving_to_start_of_previous_long_words() {
|
||||||
let tests = array::IntoIter::new([
|
let tests = [
|
||||||
(
|
(
|
||||||
"Basic backward motion from the middle of a word",
|
"Basic backward motion from the middle of a word",
|
||||||
vec![(1, Range::new(3, 3), Range::new(4, 0))],
|
vec![(1, Range::new(3, 3), Range::new(4, 0))],
|
||||||
|
@ -870,7 +868,7 @@ mod test {
|
||||||
vec![
|
vec![
|
||||||
(1, Range::new(0, 8), Range::new(8, 0)),
|
(1, Range::new(0, 8), Range::new(8, 0)),
|
||||||
]),
|
]),
|
||||||
]);
|
];
|
||||||
|
|
||||||
for (sample, scenario) in tests {
|
for (sample, scenario) in tests {
|
||||||
for (count, begin, expected_end) in scenario.into_iter() {
|
for (count, begin, expected_end) in scenario.into_iter() {
|
||||||
|
@ -882,7 +880,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_behaviour_when_moving_to_end_of_next_words() {
|
fn test_behaviour_when_moving_to_end_of_next_words() {
|
||||||
let tests = array::IntoIter::new([
|
let tests = [
|
||||||
("Basic forward motion from the start of a word to the end of it",
|
("Basic forward motion from the start of a word to the end of it",
|
||||||
vec![(1, Range::new(0, 0), Range::new(0, 5))]),
|
vec![(1, Range::new(0, 0), Range::new(0, 5))]),
|
||||||
("Basic forward motion from the end of a word to the end of the next",
|
("Basic forward motion from the end of a word to the end of the next",
|
||||||
|
@ -954,7 +952,7 @@ mod test {
|
||||||
vec![
|
vec![
|
||||||
(1, Range::new(0, 0), Range::new(0, 5)),
|
(1, Range::new(0, 0), Range::new(0, 5)),
|
||||||
]),
|
]),
|
||||||
]);
|
];
|
||||||
|
|
||||||
for (sample, scenario) in tests {
|
for (sample, scenario) in tests {
|
||||||
for (count, begin, expected_end) in scenario.into_iter() {
|
for (count, begin, expected_end) in scenario.into_iter() {
|
||||||
|
@ -966,7 +964,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_behaviour_when_moving_to_end_of_previous_words() {
|
fn test_behaviour_when_moving_to_end_of_previous_words() {
|
||||||
let tests = array::IntoIter::new([
|
let tests = [
|
||||||
("Basic backward motion from the middle of a word",
|
("Basic backward motion from the middle of a word",
|
||||||
vec![(1, Range::new(9, 9), Range::new(10, 5))]),
|
vec![(1, Range::new(9, 9), Range::new(10, 5))]),
|
||||||
("Starting from after boundary retreats the anchor",
|
("Starting from after boundary retreats the anchor",
|
||||||
|
@ -1036,7 +1034,7 @@ mod test {
|
||||||
vec![
|
vec![
|
||||||
(1, Range::new(0, 10), Range::new(10, 4)),
|
(1, Range::new(0, 10), Range::new(10, 4)),
|
||||||
]),
|
]),
|
||||||
]);
|
];
|
||||||
|
|
||||||
for (sample, scenario) in tests {
|
for (sample, scenario) in tests {
|
||||||
for (count, begin, expected_end) in scenario.into_iter() {
|
for (count, begin, expected_end) in scenario.into_iter() {
|
||||||
|
@ -1048,7 +1046,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_behaviour_when_moving_to_end_of_next_long_words() {
|
fn test_behaviour_when_moving_to_end_of_next_long_words() {
|
||||||
let tests = array::IntoIter::new([
|
let tests = [
|
||||||
("Basic forward motion from the start of a word to the end of it",
|
("Basic forward motion from the start of a word to the end of it",
|
||||||
vec![(1, Range::new(0, 0), Range::new(0, 5))]),
|
vec![(1, Range::new(0, 0), Range::new(0, 5))]),
|
||||||
("Basic forward motion from the end of a word to the end of the next",
|
("Basic forward motion from the end of a word to the end of the next",
|
||||||
|
@ -1118,7 +1116,7 @@ mod test {
|
||||||
vec![
|
vec![
|
||||||
(1, Range::new(0, 0), Range::new(0, 7)),
|
(1, Range::new(0, 0), Range::new(0, 7)),
|
||||||
]),
|
]),
|
||||||
]);
|
];
|
||||||
|
|
||||||
for (sample, scenario) in tests {
|
for (sample, scenario) in tests {
|
||||||
for (count, begin, expected_end) in scenario.into_iter() {
|
for (count, begin, expected_end) in scenario.into_iter() {
|
||||||
|
|
|
@ -1938,7 +1938,7 @@ fn append_mode(cx: &mut Context) {
|
||||||
if !last_range.is_empty() && last_range.head == end {
|
if !last_range.is_empty() && last_range.head == end {
|
||||||
let transaction = Transaction::change(
|
let transaction = Transaction::change(
|
||||||
doc.text(),
|
doc.text(),
|
||||||
std::array::IntoIter::new([(end, end, Some(doc.line_ending.as_str().into()))]),
|
[(end, end, Some(doc.line_ending.as_str().into()))].into_iter(),
|
||||||
);
|
);
|
||||||
doc.apply(&transaction, view.id);
|
doc.apply(&transaction, view.id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ impl Prompt {
|
||||||
let mut char_position = char_indices
|
let mut char_position = char_indices
|
||||||
.iter()
|
.iter()
|
||||||
.position(|(idx, _)| *idx == self.cursor)
|
.position(|(idx, _)| *idx == self.cursor)
|
||||||
.unwrap_or_else(|| char_indices.len());
|
.unwrap_or(char_indices.len());
|
||||||
|
|
||||||
for _ in 0..rep {
|
for _ in 0..rep {
|
||||||
// Skip any non-whitespace characters
|
// Skip any non-whitespace characters
|
||||||
|
|
Loading…
Reference in a new issue