Skip to content

Commit

Permalink
Fix: Event::Copy and Event::Cut behave as if they select the enti…
Browse files Browse the repository at this point in the history
…re text when there is no selection. (#5115)

Fix: `Event::Copy` and `Event::Cut` behave as if they select the entire
text when there is no selection.

It's unexpected and disconcerting that this behavior occurs when there
is no selected area.
  • Loading branch information
rustbasic authored Sep 18, 2024
1 parent 24205f5 commit e31b44f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/egui/src/widgets/text_edit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,16 +893,15 @@ fn events(

Event::Copy => {
if cursor_range.is_empty() {
copy_if_not_password(ui, text.as_str().to_owned());
None
} else {
copy_if_not_password(ui, cursor_range.slice_str(text.as_str()).to_owned());
None
}
None
}
Event::Cut => {
if cursor_range.is_empty() {
copy_if_not_password(ui, text.take());
Some(CCursorRange::default())
None
} else {
copy_if_not_password(ui, cursor_range.slice_str(text.as_str()).to_owned());
Some(CCursorRange::one(text.delete_selected(&cursor_range)))
Expand Down

0 comments on commit e31b44f

Please sign in to comment.