From cfebad159f68e042fdfc6e812d9e8c35c14290eb Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Thu, 9 May 2024 12:53:01 -0400 Subject: [PATCH] fix: focus the text box when the window gains focus --- src/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.rs b/src/main.rs index eb8682b..dccaeb4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -324,6 +324,7 @@ pub enum Message { FindReplaceValueChanged(String), FindSearchValueChanged(String), FindUseRegex(bool), + Focus, GitProjectStatus(Vec<(String, PathBuf, Vec)>), Key(Modifiers, keyboard::Key), LaunchUrl(String), @@ -2342,6 +2343,12 @@ impl Application for App { self.config.vim_bindings = vim_bindings; return self.save_config(); } + Message::Focus => { + // focus the text box if context page is not shown + if !self.core.window.show_context { + return self.update_focus(); + } + } } Command::none() @@ -2660,6 +2667,9 @@ impl Application for App { event::Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => { Some(Message::Modifiers(modifiers)) } + event::Event::Window(id, window::Event::Focused) if id == window::Id::MAIN => { + Some(Message::Focus) + } _ => None, }), subscription::channel(