From 319958ec6feb1f0ca46fc064427d84abc41e45ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 9 Apr 2016 11:41:02 +0200 Subject: 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 --- vis-operators.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'vis-operators.c') 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) { -- cgit v1.2.3