mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
search: don't try to extend a search match when there is none
This commit is contained in:
parent
5e013cad78
commit
ddf4eb3b78
1 changed files with 16 additions and 1 deletions
17
search.c
17
search.c
|
|
@ -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];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue