Skip to content

Commit

Permalink
Reduce KeyPress duplication in text_editor
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Jul 26, 2024
1 parent 28d8b73 commit e73c8b0
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions widget/src/text_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,20 +1017,17 @@ impl<Message> Update<Message> {
Status::Active
};

let key_press = KeyPress {
key,
modifiers,
text,
status,
};

if let Some(key_binding) = key_binding {
key_binding(KeyPress {
key,
modifiers,
text,
status,
})
key_binding(key_press)
} else {
Binding::from_key_press(KeyPress {
key,
modifiers,
text,
status,
})
Binding::from_key_press(key_press)
}
.map(Self::Binding)
}
Expand Down

0 comments on commit e73c8b0

Please sign in to comment.