diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-01-26 19:05:14 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-01-26 19:47:43 +0000 |
| commit | 709d6deeae82049ef48af0c8a2c5076557517a7f (patch) | |
| tree | 401205392cc145b19f590c9a3944cd89a6e8f202 | |
| parent | selection: remove duplicate ‘ESC’ in switch case (diff) | |
search: fix matching of multi-column characters
We were matching the sub-sequence SPACERs as if they were regular
characters, which obviously failed.
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | search.c | 16 |
2 files changed, 14 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 198c8624..c702ed9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ * Rendering of composed characters in the scrollback search box. * IME pre-edit cursor when positioned at the end of the pre-edit string. +* Scrollback search not matching multi-column characters. ### Security @@ -345,6 +345,11 @@ search_find_next(struct terminal *term) row = term->grid->rows[end_row]; } + if (row->cells[end_col].wc == CELL_MULT_COL_SPACER) { + end_col++; + continue; + } + ssize_t additional_chars = matches_cell(term, &row->cells[end_col], i); if (additional_chars < 0) break; @@ -440,9 +445,11 @@ search_match_to_end_of_word(struct terminal *term, bool spaces_only) /* Calculate end coord - note: assumed to be valid */ for (size_t i = 0; i < len; i++) { - if (++end_col >= term->cols) { - end_row = (end_row + 1) & (term->grid->num_rows - 1); - end_col = 0; + for (size_t j = 0; j < wcwidth(term->search.buf[i]); j++) { + if (++end_col >= term->cols) { + end_row = (end_row + 1) & (term->grid->num_rows - 1); + end_col = 0; + } } } @@ -462,6 +469,9 @@ search_match_to_end_of_word(struct terminal *term, bool spaces_only) bool done = false; for (; end_col < term->cols; end_col++) { wchar_t wc = row->cells[end_col].wc; + if (wc == CELL_MULT_COL_SPACER) + continue; + if (wc == 0 || (!first && !isword(wc, spaces_only, term->conf->word_delimiters))) { done = true; break; |
