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 <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Oscar Lesta 2022-10-25 00:03:40 -03:00 committed by waddlesplash
parent 75b68ba59d
commit 62ea448683

View File

@ -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