diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-02-21 10:24:05 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-02-21 10:24:05 +0100 |
| commit | 08ecde01710143fb93808f2e728a043aa77d9ad4 (patch) | |
| tree | 94a203159fb75242b0afdbbcc398da5df878c587 | |
| parent | b8938fe1d099d1b5b6ceecda6668b879e6a49298 (diff) | |
| download | vis-08ecde01710143fb93808f2e728a043aa77d9ad4.tar.gz vis-08ecde01710143fb93808f2e728a043aa77d9ad4.tar.xz | |
vis: insert missing new line when putting at the end of file
Something like
ifoo<Escape>yyp
should produce
foo
foo
not
foofoo
as was the case before.
| -rw-r--r-- | vis-operators.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/vis-operators.c b/vis-operators.c index 6e61d46..0f3ae19 100644 --- a/vis-operators.c +++ b/vis-operators.c @@ -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; } |
