diff options
author | Matt Brubeck <mbrubeck@limpet.net> | 2016-03-24 14:22:49 -0700 |
---|---|---|
committer | Matt Brubeck <mbrubeck@limpet.net> | 2016-03-25 08:39:53 -0700 |
commit | db2c1841cbc5ecbc9ebc43f4cf85f12cf0c77ca8 (patch) | |
tree | 26b5ea54533fc499a73c99ce5f14daa2f3b9d1dc /components/script/textinput.rs | |
parent | f2f05869d6ccd445df9b73e2e8d038c6cfa9e687 (diff) | |
download | servo-db2c1841cbc5ecbc9ebc43f4cf85f12cf0c77ca8.tar.gz servo-db2c1841cbc5ecbc9ebc43f4cf85f12cf0c77ca8.zip |
Fix delete_char when selection range is empty
An empty selection range should be treated the same as no selection.
Fixes browserhtml/browserhtml#930.
Diffstat (limited to 'components/script/textinput.rs')
-rw-r--r-- | components/script/textinput.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/components/script/textinput.rs b/components/script/textinput.rs index 35b49ee57a4..40ad401a903 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -20,7 +20,7 @@ pub enum Selection { NotSelected } -#[derive(JSTraceable, Copy, Clone, HeapSizeOf)] +#[derive(JSTraceable, Copy, Clone, HeapSizeOf, PartialEq)] pub struct TextPoint { /// 0-based line number pub line: usize, @@ -123,7 +123,7 @@ impl<T: ClipboardProvider> TextInput<T> { /// Remove a character at the current editing point pub fn delete_char(&mut self, dir: Direction) { - if self.selection_begin.is_none() { + if self.selection_begin.is_none() || self.selection_begin == Some(self.edit_point) { self.adjust_horizontal_by_one(dir, Selection::Selected); } self.replace_selection(DOMString::new()); |