From e73c8b0413e7b32c13373388fe835bff74644a42 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 26 Jul 2024 10:43:36 +0200 Subject: Reduce `KeyPress` duplication in `text_editor` --- widget/src/text_editor.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'widget/src/text_editor.rs') diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index fa7863da..56fb7578 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -1017,20 +1017,17 @@ impl Update { 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) } -- cgit