aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-02-01 18:00:38 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-02-01 18:00:38 +0100
commitfca4988f377df4b4e41134f30777ec57758c7009 (patch)
tree97334e37f959ee678f0305b3fca9dc60d8d0c886
parent1b70211a26bcae1e26b17c8ed6b1d8f25e40d0a6 (diff)
downloadvis-fca4988f377df4b4e41134f30777ec57758c7009.tar.gz
vis-fca4988f377df4b4e41134f30777ec57758c7009.tar.xz
vis: insert new line after linewise change commands
This should also (at least partially) address the issues raised in #440 and #442.
-rw-r--r--vis-operators.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/vis-operators.c b/vis-operators.c
index 6f3f0d1..2a51b2f 100644
--- a/vis-operators.c
+++ b/vis-operators.c
@@ -18,7 +18,10 @@ static size_t op_delete(Vis *vis, Text *txt, OperatorContext *c) {
static size_t op_change(Vis *vis, Text *txt, OperatorContext *c) {
op_delete(vis, txt, c);
- return c->range.start;
+ size_t pos = c->range.start;
+ if (c->linewise)
+ pos = vis_text_insert_nl(vis, txt, pos > 0 ? pos-1 : pos);
+ return pos;
}
static size_t op_yank(Vis *vis, Text *txt, OperatorContext *c) {