Skip to content

Commit

Permalink
Correct select all
Browse files Browse the repository at this point in the history
Fixes assertion failure.
Set selection direction forward on select all.
  • Loading branch information
pyfisch committed Nov 7, 2018
1 parent 9c7efd9 commit 7db13e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/script/textinput.rs
Expand Up @@ -583,6 +583,7 @@ impl<T: ClipboardProvider> TextInput<T> {
let last_line = self.lines.len() - 1;
self.edit_point.line = last_line;
self.edit_point.index = self.lines[last_line].len();
self.selection_direction = SelectionDirection::Forward;
self.assert_ok_selection();
}

Expand Down
10 changes: 10 additions & 0 deletions tests/unit/script/textinput.rs
Expand Up @@ -699,3 +699,13 @@ fn test_selection_bounds() {
assert_eq!(TextPoint { line: 0, index: 0 }, textinput.selection_start());
assert_eq!(TextPoint { line: 1, index: 0 }, textinput.selection_end());
}

#[test]
fn test_select_all() {
let mut textinput = text_input(Lines::Single, "abc");
textinput.set_selection_range(2, 3, SelectionDirection::Backward);
textinput.select_all();
assert_eq!(textinput.selection_direction(), SelectionDirection::Forward);
assert_eq!(TextPoint { line: 0, index: 0 }, textinput.selection_start());
assert_eq!(TextPoint { line: 0, index: 3 }, textinput.selection_end());
}

0 comments on commit 7db13e9

Please sign in to comment.