diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-03-28 20:43:11 +0530 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2016-03-28 20:43:11 +0530 |
commit | db95de6e581f5bf03406264c7f690bca5bb4701b (patch) | |
tree | 7619ded56f197a444a54dd4e55c0cef3f7b43399 /components/script/textinput.rs | |
parent | 37799a40251ae4df695d2257f57063c37d739329 (diff) | |
parent | db2c1841cbc5ecbc9ebc43f4cf85f12cf0c77ca8 (diff) | |
download | servo-db95de6e581f5bf03406264c7f690bca5bb4701b.tar.gz servo-db95de6e581f5bf03406264c7f690bca5bb4701b.zip |
Auto merge of #10182 - mbrubeck:delete_char, r=jdm
Fix delete_char when selection range is empty
An empty selection range should be treated the same as no selection. Fixes browserhtml/browserhtml#930.
r? @jdm
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10182)
<!-- Reviewable:end -->
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 343b114bf2d..cc5936d42b0 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -21,7 +21,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, @@ -124,7 +124,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()); |