diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-01-19 13:18:20 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-01-19 13:18:20 +0100 |
| commit | a83ab01a6c3a4153d2c7bae60f8975a39d7955ca (patch) | |
| tree | 4bbb346d62733444818b4f75630b2f1940115bb1 /vis.c | |
| parent | 48ce013f1df470b340908f02d4ea87c812f902f7 (diff) | |
| download | vis-a83ab01a6c3a4153d2c7bae60f8975a39d7955ca.tar.gz vis-a83ab01a6c3a4153d2c7bae60f8975a39d7955ca.tar.xz | |
vis: improve selection restore `gv`
Diffstat (limited to 'vis.c')
| -rw-r--r-- | vis.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -519,7 +519,18 @@ void action_do(Vis *vis, Action *a) { if (pos == EPOS) { view_cursors_dispose(cursor); } else if (pos <= text_size(txt)) { + /* moving the cursor will affect the selection. + * because we want to be able to later restore + * the old selection we update it again before + * leaving visual mode. + */ + Filerange sel = view_cursors_selection_get(cursor); view_cursors_to(cursor, pos); + if (vis->mode->visual) { + if (vis->mode == &vis_modes[VIS_MODE_VISUAL_LINE]) + sel = text_range_linewise(txt, &sel); + view_cursors_selection_set(cursor, &sel); + } } } } |
