From 62ea448683e1da520be8d3c51bc02bb00bd129b4 Mon Sep 17 00:00:00 2001 From: Oscar Lesta Date: Tue, 25 Oct 2022 00:03:40 -0300 Subject: [PATCH] TextSearch: do not trigger new grep searches unnecessarily. Opening and closing a file from the results window with Pe, for example, was triggering unnecessary new grep searches, when only the attributes or other metadata on the file got changed (and not its content). That new search was also changing the focus from the results view to the search field (making one lose the position on that list, specially annoying with large number of results). Avoid that by not monitoring/reacting to B_ATTR_CHANGED, and not reacting to B_STAT_CHANGED if the only flag is B_STAT_CHANGE_TIME. Change-Id: I56d34c93da94acf36890abe458da45d26a334593 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5763 Tested-by: Commit checker robot Reviewed-by: waddlesplash --- src/apps/text_search/GrepWindow.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/apps/text_search/GrepWindow.cpp b/src/apps/text_search/GrepWindow.cpp index 8db213cfa5..c77b1004bd 100644 --- a/src/apps/text_search/GrepWindow.cpp +++ b/src/apps/text_search/GrepWindow.cpp @@ -676,7 +676,7 @@ GrepWindow::_StartNodeMonitoring() _StopNodeMonitoring(); BMessenger messenger(this); - uint32 fileFlags = B_WATCH_NAME | B_WATCH_STAT | B_WATCH_ATTR; + uint32 fileFlags = B_WATCH_NAME | B_WATCH_STAT; // watch the top level folder only, rest should be done through filtering @@ -905,10 +905,16 @@ GrepWindow::_OnNodeMonitorEvent(BMessage* message) break; } case B_STAT_CHANGED: - case B_ATTR_CHANGED: { - TRACE_NM("%s\n", opCode == B_STAT_CHANGED ? "B_STAT_CHANGED" - : "B_ATTR_CHANGED"); + int32 fields; + message->FindInt32("fields", &fields); + + TRACE_NM("B_STAT_CHANGED (fields = 0x%" B_PRIx32 ")\n", fields); + + // No point in triggering a new search if this was the only change. + if (fields == B_STAT_CHANGE_TIME) + break; + // For directly watched files, the path will include the // name. When the event occurs for a file in a watched directory, // the message will have an extra name field for the respective