diff options
Diffstat (limited to 'vis-operators.c')
| -rw-r--r-- | vis-operators.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/vis-operators.c b/vis-operators.c index 0923ef6..981922b 100644 --- a/vis-operators.c +++ b/vis-operators.c @@ -30,12 +30,18 @@ static size_t op_yank(Vis *vis, Text *txt, OperatorContext *c) { static size_t op_put(Vis *vis, Text *txt, OperatorContext *c) { size_t pos = c->pos; + bool sel = text_range_size(&c->range) > 0; + bool sel_linewise = sel && text_range_is_linewise(txt, &c->range); + if (sel) { + text_delete_range(txt, &c->range); + pos = c->pos = c->range.start; + } switch (c->arg->i) { case VIS_OP_PUT_AFTER: case VIS_OP_PUT_AFTER_END: - if (c->reg->linewise) + if (c->reg->linewise && !sel_linewise) pos = text_line_next(txt, pos); - else + else if (!sel) pos = text_char_next(txt, pos); break; case VIS_OP_PUT_BEFORE: |
