diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-01-19 15:34:45 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-01-19 16:33:06 +0100 |
| commit | 0803eef3ecf0f585a8ecbc0b9e009864111ba0be (patch) | |
| tree | b1e6990e9e4ec442a8ce2c3a112a1f8b3fc50802 /main.c | |
| parent | 5c4dc39baff46b9a9ce328b16592e0bebf12217e (diff) | |
| download | vis-0803eef3ecf0f585a8ecbc0b9e009864111ba0be.tar.gz vis-0803eef3ecf0f585a8ecbc0b9e009864111ba0be.tar.xz | |
vis: make <C-n> in visual mode wrap around
Strictly speaking we actually not wrap around, but search
backwards starting from the first cursor. This is seems
more useful when for example renaming a local variable
but not starting from its declaration.
Close #305
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -1442,15 +1442,22 @@ static const char *cursors_select_next(Vis *vis, const char *keys, const Arg *ar if (!buf) return keys; Filerange word = text_object_word_find_next(txt, sel.end, buf); - free(buf); - if (text_range_valid(&word)) { size_t pos = text_char_prev(txt, word.end); - cursor = view_cursors_new(view, pos); - if (!cursor) - return keys; - view_cursors_selection_set(cursor, &word); + if ((cursor = view_cursors_new(view, pos))) { + view_cursors_selection_set(cursor, &word); + goto out; + } } + + sel = view_cursors_selection_get(view_cursors(view)); + word = text_object_word_find_prev(txt, sel.start, buf); + size_t pos = text_char_prev(txt, word.end); + if ((cursor = view_cursors_new(view, pos))) + view_cursors_selection_set(cursor, &word); + +out: + free(buf); return keys; } |
