diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2020-08-29 18:17:43 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2020-08-29 18:19:36 +0200 |
| commit | 4b2aa76ea98f9219b46a775f393955b4fdb23cbd (patch) | |
| tree | 86dfa1a98157981762add8cc667aa189730c2003 | |
| parent | 08d2e6964eee74a156e6ca4996e90f5e0a2d676f (diff) | |
| download | vis-4b2aa76ea98f9219b46a775f393955b4fdb23cbd.tar.gz vis-4b2aa76ea98f9219b46a775f393955b4fdb23cbd.tar.xz | |
vis: improve C-n behavior in visual mode
Determine the matching behavior based on the first (not primary)
selection.
Fix #864
| -rw-r--r-- | main.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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; |
