vis

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

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

commit 5d7fcdc1a0bf58632298fa36ae83bcefc421a4b7
parent 823d492a3768435bf6f8ffca418452135b3d1eae
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sat, 29 Aug 2020 18:17:43 +0200

vis: improve C-n behavior in visual mode

Determine the matching behavior based on the first (not primary)
selection.

Fix #864

Diffstat:
Mmain.c | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/main.c b/main.c @@ -1376,15 +1376,21 @@ static const char *selections_match_next(Vis *vis, const char *keys, const Arg * if (!text_range_valid(&sel)) return keys; - Filerange word = text_object_word(txt, view_cursors_pos(s)); - if (!text_range_equal(&sel, &word)) + static bool match_word; + + if (view_selections_count(view) == 1) { + Filerange word = text_object_word(txt, view_cursors_pos(s)); + match_word = text_range_equal(&sel, &word); + } + + if (!match_word) return selections_match_next_literal(vis, keys, arg); char *buf = text_bytes_alloc0(txt, sel.start, text_range_size(&sel)); if (!buf) return keys; - word = text_object_word_find_next(txt, sel.end, buf); + Filerange word = text_object_word_find_next(txt, sel.end, buf); if (text_range_valid(&word) && selection_new_primary(view, &word)) goto out;