From 2fa2d749e675cc95ad5c6e866d3257639b136df8 Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Wed, 5 Nov 2025 22:00:15 +0100 Subject: Fix searching annoyances - It now colors correctly - Supports searching for unicode symbols - Make search able to continue when more letters are entered --- src/main/search-replace.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/main/search-replace.c') diff --git a/src/main/search-replace.c b/src/main/search-replace.c index 1910a37..3893bd3 100644 --- a/src/main/search-replace.c +++ b/src/main/search-replace.c @@ -487,9 +487,20 @@ int32_t find(struct command_ctx ctx, int argc, const char *argv[]) { return minibuffer_prompt(ctx, search_prompt(reverse)); } - // allow enter to end the interactive search - if (g_current_search.active) { + // allow enter to end the interactive search if it is already + // what we are searching for. + struct text_chunk line = minibuffer_content(); + char *l = (char *)malloc(line.nbytes + 1); + memcpy(l, line.text, line.nbytes); + l[line.nbytes] = '\0'; + + if (g_current_search.active && strcmp(g_current_search.pattern, l) == 0) { abort_search(); + + if (line.allocated) { + free(line.text); + } + free(l); return 0; } @@ -497,13 +508,7 @@ int32_t find(struct command_ctx ctx, int argc, const char *argv[]) { * Use the full minibuffer content here, not individual * arguments. */ - struct text_chunk line = minibuffer_content(); - char *l = (char *)malloc(line.nbytes + 1); - memcpy(l, line.text, line.nbytes); - l[line.nbytes] = '\0'; - bool found = do_search(window_buffer_view(ctx.active_window), l, reverse); - if (line.allocated) { free(line.text); } -- cgit v1.2.3