vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 6a0bacf83c8b1e66fd28b14b64c1eabde3b341d5
parent e7e9ff1e8c59afa606984d52c605ee1d4a7e5e22
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sat,  8 Jul 2017 12:27:51 +0200

view: keep but clear primary selection if instructed to replace all

Previously the last selection was kept implicitly to statisfy the invariant
that at least one selection needs to exist.

Diffstat:
Mview.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/view.c b/view.c @@ -1260,7 +1260,10 @@ void view_selections_set_all(View *view, Array *arr, bool anchored) { if (!(r = array_get(arr, i++)) || !view_selections_set(s, r)) { for (Selection *next; s; s = next) { next = view_selections_next(s); - view_selections_dispose(s); + if (i == 1 && s == view->selection) + view_selection_clear(s); + else + view_selections_dispose(s); } break; }