mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
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 -->
This commit is contained in:
commit
db95de6e58
2 changed files with 9 additions and 2 deletions
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue