Skip to content

Commit

Permalink
vis: insert missing new line when putting at the end of file
Browse files Browse the repository at this point in the history
Something like

  ifoo<Escape>yyp

should produce

  foo
  foo

not

  foofoo

as was the case before.
  • Loading branch information
martanne committed Feb 21, 2016
1 parent b8938fe commit 08ecde0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vis-operators.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ static size_t op_put(Vis *vis, Text *txt, OperatorContext *c) {
const char *data = register_get(vis, c->reg, &len);

for (int i = 0; i < c->count; i++) {
char nl;
if (c->reg->linewise && pos > 0 && text_byte_get(txt, pos-1, &nl) && nl != '\n')
pos += text_insert_newline(txt, pos);
text_insert(txt, pos, data, len);
pos += len;
}
Expand Down

0 comments on commit 08ecde0

Please sign in to comment.