summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2025-11-05 22:00:15 +0100
committerAlbert Cervin <albert@acervin.com>2025-11-05 22:00:15 +0100
commit2fa2d749e675cc95ad5c6e866d3257639b136df8 (patch)
tree2b7cf36ab7fb90125425ef23df825d5f93754d12 /src/main
parent9ed37096c4e79169ebd6a037805ff7f2754326f7 (diff)
downloaddged-2fa2d749e675cc95ad5c6e866d3257639b136df8.tar.gz
dged-2fa2d749e675cc95ad5c6e866d3257639b136df8.tar.xz
dged-2fa2d749e675cc95ad5c6e866d3257639b136df8.zip
Fix searching annoyances
- It now colors correctly - Supports searching for unicode symbols - Make search able to continue when more letters are entered
Diffstat (limited to 'src/main')
-rw-r--r--src/main/search-replace.c21
1 files changed, 13 insertions, 8 deletions
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);
}