summaryrefslogtreecommitdiff
path: root/src/search.cpp
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2024-03-03 21:14:08 +0100
committerAldrik Ramaekers <aldrikboy@gmail.com>2024-03-03 21:14:08 +0100
commit26bb40b2f9cf10eb8aaf4f6ac53585ef73be5134 (patch)
tree42766231bc5c69c347ebd239c9451b08128ec0ba /src/search.cpp
parent16d695eee026947899f2168905bae39f4e3c5895 (diff)
implement file filtering
Diffstat (limited to 'src/search.cpp')
-rw-r--r--src/search.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/search.cpp b/src/search.cpp
index 76d7b92..e90e433 100644
--- a/src/search.cpp
+++ b/src/search.cpp
@@ -71,7 +71,10 @@ int ts_filter_matches(ts_array *filters, char *string, char **matched_filter)
for (int i = 0; i < filters->length; i++)
{
char *filter = (char *)ts_array_at(filters, i);
- if (ts_string_match(filter, string))
+
+ char wildcard_filter[MAX_INPUT_LENGTH];
+ snprintf(wildcard_filter, MAX_INPUT_LENGTH, "*%s", filter);
+ if (ts_string_match(wildcard_filter, string))
{
*matched_filter = filter;
return strlen(filter);
@@ -357,6 +360,7 @@ void ts_start_search(utf8_int8_t *path, utf8_int8_t *filter, utf8_int8_t *query)
ts_search_result *new_result = ts_create_empty_search_result();
snprintf(new_result->directory_to_search, MAX_INPUT_LENGTH, "%s", path);
snprintf(new_result->search_text, MAX_INPUT_LENGTH, "%s", query);
+ new_result->filters = ts_get_filters(filter);
_ts_list_files(new_result);
for (int i = 0; i < new_result->max_ts_thread_count; i++)