aboutsummaryrefslogtreecommitdiff
path: root/vis-operators.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-04-09 11:41:02 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-04-09 12:08:42 +0200
commit319958ec6feb1f0ca46fc064427d84abc41e45ce (patch)
tree478593cee65ee6d6c001be9d7639b990a698a134 /vis-operators.c
parent77d229c0a5d642b57e51270a2e85c48dc2273598 (diff)
downloadvis-319958ec6feb1f0ca46fc064427d84abc41e45ce.tar.gz
vis-319958ec6feb1f0ca46fc064427d84abc41e45ce.tar.xz
vis: make sure linewise put operations insert necessary new lines
Given the following text with no trailing new line at the end of line2, where # denotes the cursor position: line1 of text line2 #f text the command yykp should produce line1 of text #ine2 of text line2 of text where previously it would wrongly result in line1 of text #ine1 of textline2 of text
Diffstat (limited to 'vis-operators.c')
-rw-r--r--vis-operators.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/vis-operators.c b/vis-operators.c
index 0be30ad..5fb33b1 100644
--- a/vis-operators.c
+++ b/vis-operators.c
@@ -62,6 +62,8 @@ static size_t op_put(Vis *vis, Text *txt, OperatorContext *c) {
pos += text_insert_newline(txt, pos);
text_insert(txt, pos, data, len);
pos += len;
+ if (c->reg->linewise && pos > 0 && text_byte_get(txt, pos-1, &nl) && nl != '\n')
+ pos += text_insert_newline(txt, pos);
}
if (c->reg->linewise) {