diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-07-09 10:12:25 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-07-09 10:12:25 +0200 |
| commit | 66f5700d201c9456f917507db77a88115f38961c (patch) | |
| tree | a9abe0cbb1d148ccbc74f0eace1ca6062f7c3b7a /vis.c | |
| parent | 37fcfd0881ffdf99d85388ef6753d0e9e34f36cd (diff) | |
| download | vis-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.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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) { |
