diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2023-09-27 16:36:52 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2023-10-08 08:38:39 +0000 |
| commit | ddf4eb3b78ebe590d0dd6675536f9a7e4043ee71 (patch) | |
| tree | a7f74582d986ff077789727f56aeffbba9ee633c | |
| parent | selection: selection_update() uses view-local coordinates (diff) | |
search: don't try to extend a search match when there is none
| -rw-r--r-- | search.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -705,6 +705,9 @@ static void search_extend_find_char(const struct terminal *term, struct coord *target, enum extend_direction direction) { + if (term->search.match_len == 0) + return; + struct coord pos = direction == SEARCH_EXTEND_LEFT ? selection_get_start(term) : selection_get_end(term); xassert(pos.row >= 0); @@ -753,11 +756,14 @@ static void search_extend_find_word(const struct terminal *term, bool spaces_only, struct coord *target, enum extend_direction direction) { + if (term->search.match_len == 0) + return; + struct grid *grid = term->grid; struct coord pos = direction == SEARCH_EXTEND_LEFT ? selection_get_start(term) : selection_get_end(term); - + xassert(pos.row >= 0); xassert(pos.row < grid->num_rows); @@ -812,6 +818,9 @@ static void search_extend_find_line(const struct terminal *term, struct coord *target, enum extend_direction direction) { + if (term->search.match_len == 0) + return; + struct coord pos = direction == SEARCH_EXTEND_LEFT ? selection_get_start(term) : selection_get_end(term); @@ -854,6 +863,9 @@ search_extend_find_line_down(const struct terminal *term, struct coord *target) static void search_extend_left(struct terminal *term, const struct coord *target) { + if (term->search.match_len == 0) + return; + const struct coord last_coord = selection_get_start(term); struct coord pos = *target; const struct row *row = term->grid->rows[pos.row]; @@ -916,6 +928,9 @@ search_extend_left(struct terminal *term, const struct coord *target) static void search_extend_right(struct terminal *term, const struct coord *target) { + if (term->search.match_len == 0) + return; + struct coord pos = selection_get_end(term); const struct row *row = term->grid->rows[pos.row]; |
