From 52678afa4ffe500b72f5e32be94e4cbfcc74c4fa Mon Sep 17 00:00:00 2001
From: Pratik Borhade <pratikborhade302@gmail.com>
Date: Tue, 14 Nov 2023 12:31:55 +0100
Subject: [PATCH] Fix #114758: keep text field empty for global search

Revert cea02c15f810beba5dd65a300a6389ccc29970ad. This will fix the issue
mentioned in #114758 and it will also allow user to see recent
searches in the list below the search box (F3).

Pull Request: https://projects.blender.org/blender/blender/pulls/114774
---
 source/blender/windowmanager/intern/wm_operators.cc | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/source/blender/windowmanager/intern/wm_operators.cc b/source/blender/windowmanager/intern/wm_operators.cc
index cc8bcdf7b99..195660a3340 100644
--- a/source/blender/windowmanager/intern/wm_operators.cc
+++ b/source/blender/windowmanager/intern/wm_operators.cc
@@ -1856,8 +1856,6 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *eve
   }
 
   static SearchPopupInit_Data data{};
-  char temp_buffer[256] = "";
-  STRNCPY(temp_buffer, g_search_text);
 
   if (search_type == SEARCH_TYPE_SINGLE_MENU) {
     {
@@ -1871,6 +1869,9 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *eve
       MEM_SAFE_FREE(buffer);
     }
   }
+  else {
+    g_search_text[0] = '\0';
+  }
 
   data.search_type = search_type;
   data.size[0] = UI_searchbox_size_x() * 2;
@@ -1878,10 +1879,6 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *eve
 
   UI_popup_block_invoke_ex(C, wm_block_search_menu, &data, nullptr, false);
 
-  /* g_search_text contains pressed letter here, copy previous searched
-   * value back to it, this will retain last searched result. see: #112896 */
-  STRNCPY(g_search_text, temp_buffer);
-
   return OPERATOR_INTERFACE;
 }
 
-- 
GitLab