aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-07-09 10:12:25 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-07-09 10:12:25 +0200
commit66f5700d201c9456f917507db77a88115f38961c (patch)
treea9abe0cbb1d148ccbc74f0eace1ca6062f7c3b7a /vis.c
parent37fcfd0881ffdf99d85388ef6753d0e9e34f36cd (diff)
downloadvis-66f5700d201c9456f917507db77a88115f38961c.tar.gz
vis-66f5700d201c9456f917507db77a88115f38961c.tar.xz
vis: improve handling of linewise deletion at end of file
dd on the last line now moves the cursor to the start of the preceding line.
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/vis.c b/vis.c
index 8cab79a..ee6612b 100644
--- a/vis.c
+++ b/vis.c
@@ -447,13 +447,16 @@ static size_t op_delete(OperatorContext *c) {
c->reg->linewise = c->linewise;
register_put(c->reg, txt, &c->range);
text_delete(txt, c->range.start, len);
- return c->range.start;
+ size_t pos = c->range.start;
+ if (c->linewise && pos == text_size(txt))
+ pos = text_line_begin(txt, text_line_prev(txt, pos));
+ return pos;
}
static size_t op_change(OperatorContext *c) {
- size_t pos = op_delete(c);
+ op_delete(c);
switchmode(&(const Arg){ .i = VIS_MODE_INSERT });
- return pos;
+ return c->range.start;
}
static size_t op_yank(OperatorContext *c) {