aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-11-27 07:15:34 +0100
committerMarc André Tanner <mat@brain-dump.org>2015-11-27 07:15:34 +0100
commite063464c7cdeb41796282d0efe13cc907928f3f8 (patch)
tree28b75caab90c530b8b8f6b72b9b2531d658399b8
parenta9decb9940ad33e1111364b7e493fb63b1778a0f (diff)
downloadvis-e063464c7cdeb41796282d0efe13cc907928f3f8.tar.gz
vis-e063464c7cdeb41796282d0efe13cc907928f3f8.tar.xz
vis: change semantics of operator implementation return value
The return value of operator implementations denoting the new cursor position is interpreted in the following way: - EPOS dispose the cursor - [0, text_size] place the cursor accordingly - otherwise i.e. > text_size keep the cursor position unchanged The newly introduced last case is useful for operators which are called from visual mode, but do not want to change the current selection.
-rw-r--r--vis.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/vis.c b/vis.c
index 03dcc61..3398c6c 100644
--- a/vis.c
+++ b/vis.c
@@ -645,10 +645,10 @@ static void action_do(Vis *vis, Action *a) {
if (a->op) {
size_t pos = a->op->func(vis, txt, &c);
- if (pos != EPOS) {
- view_cursors_to(cursor, pos);
- } else {
+ if (pos == EPOS) {
view_cursors_dispose(cursor);
+ } else if (pos <= text_size(txt)) {
+ view_cursors_to(cursor, pos);
}
}
}