aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-06-13 14:30:56 +0200
committerMarc André Tanner <mat@brain-dump.org>2017-06-15 15:51:43 +0200
commit21adfe438b32cd0cd41ca00e99adfe827c4f4a95 (patch)
tree511abd57bc289174da5821c7109d26e9c2b53e72
parenta845dec7336c379d007832cbc5ff9abbb9fe1dab (diff)
downloadvis-21adfe438b32cd0cd41ca00e99adfe827c4f4a95.tar.gz
vis-21adfe438b32cd0cd41ca00e99adfe827c4f4a95.tar.xz
view: do not automatically anchor selections when setting range
-rw-r--r--main.c2
-rw-r--r--view.c1
-rw-r--r--vis-lua.c6
-rw-r--r--vis.c4
4 files changed, 9 insertions, 4 deletions
diff --git a/main.c b/main.c
index 3f73b6e..db8e969 100644
--- a/main.c
+++ b/main.c
@@ -1380,6 +1380,7 @@ static const char *cursors_select_next(Vis *vis, const char *keys, const Arg *ar
size_t pos = text_char_prev(txt, word.end);
if ((s = view_selections_new(view, pos))) {
view_selections_set(s, &word);
+ view_selections_anchor(s);
view_selections_primary_set(s);
goto out;
}
@@ -1392,6 +1393,7 @@ static const char *cursors_select_next(Vis *vis, const char *keys, const Arg *ar
size_t pos = text_char_prev(txt, word.end);
if ((s = view_selections_new(view, pos))) {
view_selections_set(s, &word);
+ view_selections_anchor(s);
view_selections_primary_set(s);
}
diff --git a/view.c b/view.c
index 1233b24..14cc4aa 100644
--- a/view.c
+++ b/view.c
@@ -1227,7 +1227,6 @@ void view_selections_set(Selection *s, const Filerange *r) {
s->anchor = text_mark_set(txt, r->start);
s->cursor = text_mark_set(txt, end);
}
- s->anchored = true;
view_cursors_to(s, text_mark_get(s->view->text, s->cursor));
}
diff --git a/vis-lua.c b/vis-lua.c
index d5cfa98..5fe006c 100644
--- a/vis-lua.c
+++ b/vis-lua.c
@@ -1887,10 +1887,12 @@ static int window_cursor_newindex(lua_State *L) {
if (strcmp(key, "selection") == 0) {
Filerange range = getrange(L, 3);
- if (text_range_valid(&range))
+ if (text_range_valid(&range)) {
view_selections_set(sel, &range);
- else
+ view_selections_anchor(sel);
+ } else {
view_selection_clear(sel);
+ }
return 0;
}
}
diff --git a/vis.c b/vis.c
index 1ba6ff2..cd22e4d 100644
--- a/vis.c
+++ b/vis.c
@@ -971,8 +971,10 @@ void vis_do(Vis *vis) {
if (linewise && vis->mode != &vis_modes[VIS_MODE_VISUAL])
c.range = text_range_linewise(txt, &c.range);
- if (vis->mode->visual)
+ if (vis->mode->visual) {
view_selections_set(sel, &c.range);
+ view_selections_anchor(sel);
+ }
if (a->op) {
size_t pos = a->op->func(vis, txt, &c);