Repository: lapce/lapce (language: rust)

Issue:
find (e.g. ctr+f)  freezes after one use
## Lapce Version
Lapce nightly


## System information

fedora 39
dell inspiron

## Describe the bug
find (e.g. ctr+f)  freezes after one use
needs to be restarted

## Additional information
the replace function never works, can't ever add text into it

Other information that can be used to further reproduce or isolate the problem.
- workarounds that you used

I just have to close and open it again but it is very frustrating and prone to injecting typos into the code
because I can never tell where the text will appear.

ctr+d is a life-saver and usually works well, main reason why I use Lapce as my main editor.




Discussion / hints:
Reproducing instructions since it took me a bit to get what the issue meant, I'll make a PR for this:
- Ctrl + F
- type something like "Vec"
- Press enter and you can go forward between the different selections
- click off the find input, such as into the editor
- click back into the find input, enter no longer works to move between entries and you can't type in it

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7f3e96e6c5..b327915a6c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
 
 ### Bug Fixes
 - [#2779](https://github.com/lapce/lapce/pull/2779): Fix files detection on fresh git/VCS repository
+- [#3031](https://github.com/lapce/lapce/pull/3031): Fix find not receiving inputs when clicked
 
 ## 0.3.1
 
diff --git a/lapce-app/src/app.rs b/lapce-app/src/app.rs
index 90a5902af1..68b2661295 100644
--- a/lapce-app/src/app.rs
+++ b/lapce-app/src/app.rs
@@ -420,8 +420,10 @@ impl AppData {
     }
 
     fn app_view(&self, window_id: WindowId, info: WindowInfo) -> impl View {
+        let app_view_id = create_rw_signal(floem::id::Id::next());
         let window_data = WindowData::new(
             window_id,
+            app_view_id,
             info,
             self.window_scale,
             self.latest_release.read_only(),
@@ -521,6 +523,8 @@ impl AppData {
             ))
             .style(|s| s.flex_col().size_full());
         let view_id = view.id();
+        app_view_id.set(view_id);
+
         view.window_scale(move || window_scale.get())
             .keyboard_navigatable()
             .on_event(EventListener::KeyDown, move |event| {
diff --git a/lapce-app/src/editor/view.rs b/lapce-app/src/editor/view.rs
index 1cf792af6f..1693be44cf 100644
--- a/lapce-app/src/editor/view.rs
+++ b/lapce-app/src/editor/view.rs
@@ -1882,10 +1882,11 @@ fn find_view(
     replace_focus: RwSignal<bool>,
     is_active: impl Fn(bool) -> bool + 'static + Copy,
 ) -> impl View {
-    let config = find_editor.common.config;
-    let find_visual = find_editor.common.find.visual;
+    let common = find_editor.common.clone();
+    let config = common.config;
+    let find_visual = common.find.visual;
     let replace_doc = replace_editor.doc_signal();
-    let focus = find_editor.common.focus;
+    let focus = common.focus;
 
     let find_pos = create_memo(move |_| {
         let visual = find_visual.get();
@@ -2036,6 +2037,9 @@ fn find_view(
                 .flex_col()
         })
         .on_event_stop(EventListener::PointerDown, move |_| {
+            // Shift the editor tab focus to the editor the find search is attached to
+            // So that if you have two tabs open side-by-side (and thus two find views),
+            // clicking on one will shift the focus to the editor it's attached to
             let editor = editor.get_untracked();
             if let Some(editor_tab_id) = editor.editor_tab_id.get_untracked() {
                 editor
@@ -2044,6 +2048,15 @@ fn find_view(
                     .send(InternalCommand::FocusEditorTab { editor_tab_id });
             }
             focus.set(Focus::Workbench);
+            // Request focus on the app view, as our current method of dispatching pointer events
+            // is from the app_view to the actual editor. That's also why this stops the pointer
+            // event is stopped here, as otherwise our default handling would make it go through to
+            // the editor.
+            common
+                .window_common
+                .app_view_id
+                .get_untracked()
+                .request_focus();
         }),
     )
     .style(move |s| {
diff --git a/lapce-app/src/window.rs b/lapce-app/src/window.rs
index 5eedc6b993..920562ce5c 100644
--- a/lapce-app/src/window.rs
+++ b/lapce-app/src/window.rs
@@ -47,6 +47,7 @@ pub struct WindowCommonData {
     pub cursor_blink_timer: RwSignal<TimerToken>,
     // the value to be update by curosr blinking
     pub hide_cursor: RwSignal<bool>,
+    pub app_view_id: RwSignal<floem::id::Id>,
 }
 
 /// `WindowData` is the application model for a top-level window.
@@ -80,6 +81,7 @@ pub struct WindowData {
 impl WindowData {
     pub fn new(
         window_id: WindowId,
+        app_view_id: RwSignal<floem::id::Id>,
         info: WindowInfo,
         window_scale: RwSignal<f64>,
         latest_release: ReadSignal<Arc<Option<ReleaseInfo>>>,
@@ -113,6 +115,7 @@ impl WindowData {
             ime_allowed,
             cursor_blink_timer,
             hide_cursor,
+            app_view_id,
         });
 
         for w in info.tabs.workspaces {


Test patch: