diff options
Diffstat (limited to 'src/text')
| -rw-r--r-- | src/text/rich.rs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/text/rich.rs b/src/text/rich.rs index a30663b..5ca3051 100644 --- a/src/text/rich.rs +++ b/src/text/rich.rs @@ -600,7 +600,7 @@ where let click_position = cursor.position_in(bounds); if viewport.intersection(&bounds).is_none() - && state.selection == Selection::default() + && state.selection.is_empty() && state.dragging.is_none() { return; @@ -720,7 +720,14 @@ where state.selection.change_selection(new_end); } - Dragging::Word => {} + Dragging::Word => { + let new_end = SelectionEnd { line, index }; + + state.selection.change_selection_by_word( + new_end, + &state.paragraph, + ); + } Dragging::Line => { state.selection.change_selection_by_line( line, @@ -745,7 +752,7 @@ where } keyboard::Key::Character("a") if state.keyboard_modifiers.command() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { state.selection.select_all(&state.paragraph); @@ -753,7 +760,7 @@ where } keyboard::Key::Named(key::Named::Home) if state.keyboard_modifiers.shift() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { if state.keyboard_modifiers.jump() { state.selection.select_beginning(); @@ -765,7 +772,7 @@ where } keyboard::Key::Named(key::Named::End) if state.keyboard_modifiers.shift() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { if state.keyboard_modifiers.jump() { state.selection.select_end(&state.paragraph); @@ -777,7 +784,7 @@ where } keyboard::Key::Named(key::Named::ArrowLeft) if state.keyboard_modifiers.shift() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { if state.keyboard_modifiers.macos_command() { state.selection.select_line_beginning(); @@ -793,7 +800,7 @@ where } keyboard::Key::Named(key::Named::ArrowRight) if state.keyboard_modifiers.shift() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { if state.keyboard_modifiers.macos_command() { state.selection.select_line_end(&state.paragraph); @@ -809,7 +816,7 @@ where } keyboard::Key::Named(key::Named::ArrowUp) if state.keyboard_modifiers.shift() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { if state.keyboard_modifiers.macos_command() { state.selection.select_beginning(); @@ -823,7 +830,7 @@ where } keyboard::Key::Named(key::Named::ArrowDown) if state.keyboard_modifiers.shift() - && state.selection != Selection::default() => + && !state.selection.is_empty() => { if state.keyboard_modifiers.macos_command() { state.selection.select_end(&state.paragraph); |
