aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-04-17 17:16:47 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-04-17 17:16:47 +0000
commitc5519e2aa6aacc7b552bd4d629b21e00051c211a (patch)
treef3909884f6845fc84712463537d2885802069e94
parentwayland: refactor: remove ‘struct config’ pointer from wayland struct (diff)
search: fix next/prev not updating selection correctly when matches overlap
When the new match overlapped with the old match, the selection wasn’t updated correctly.
-rw-r--r--CHANGELOG.md2
-rw-r--r--search.c10
-rw-r--r--selection.c2
3 files changed, 11 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 28c2e856..38450ab3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -123,6 +123,8 @@
are enabled, and CSD border width set to a non-zero value.
* Key binding overrides on the command line having no effect with
`footclient` instances (https://codeberg.org/dnkl/foot/issues/931).
+* Search prev/next not updating the selection correctly when the
+ previous and new match overlaps.
### Security
diff --git a/search.c b/search.c
index 2a7903d7..0ae09fde 100644
--- a/search.c
+++ b/search.c
@@ -235,9 +235,15 @@ search_update_selection(struct terminal *term, const struct range *match)
}
#endif
- /* Begin a new selection if the start coords changed */
+ /*
+ * Begin a new selection if the start coords changed
+ *
+ * Note: check column against selection.coords, since our “old”
+ * start column isn’t reliable - we modify it when searching
+ * “next” or “prev”.
+ */
if (start_row != term->search.match.row ||
- start_col != term->search.match.col)
+ start_col != term->selection.coords.start.col)
{
int selection_row = start_row - grid->view + grid->num_rows;
selection_row &= grid->num_rows - 1;
diff --git a/selection.c b/selection.c
index a4bc5f3b..f279a834 100644
--- a/selection.c
+++ b/selection.c
@@ -42,7 +42,7 @@ bool
selection_on_rows(const struct terminal *term, int row_start, int row_end)
{
LOG_DBG("on rows: %d-%d, range: %d-%d (offset=%d)",
- term->selection.start.row, term->selection.end.row,
+ term->selection.coords.start.row, term->selection.coords.end.row,
row_start, row_end, term->grid->offset);
if (term->selection.coords.end.row < 0)