diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-06-30 18:56:18 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-06-30 18:56:18 +0100 |
| commit | b18db68c8a6b83192d5765fbffc5fd47dbb2fb5a (patch) | |
| tree | 1ebf5c370225b0a6de12b577e0af844324d32a57 /src/buffer_utils.cc | |
| parent | d6bb5b5a4b4b7147762a09e04fedb91ff2ee19f3 (diff) | |
Fix spurious eol appearing in non scrolling fifo buffers
Diffstat (limited to 'src/buffer_utils.cc')
| -rw-r--r-- | src/buffer_utils.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/buffer_utils.cc b/src/buffer_utils.cc index 5f8cb9fd..c59157a5 100644 --- a/src/buffer_utils.cc +++ b/src/buffer_utils.cc @@ -47,10 +47,13 @@ Buffer* create_fifo_buffer(String name, int fd, bool scroll) buffer->insert(pos, count > 0 ? String(data, data+count) : "*** kak: fifo closed ***\n"); - if (prevent_scrolling) + if (count > 0 and prevent_scrolling) { buffer->erase(buffer->begin(), buffer->begin()+1); - buffer->insert(buffer->end(), "\n"); + // in the other case, the buffer will have automatically + // inserted a \n to guarantee its invariant. + if (data[count-1] == '\n') + buffer->insert(buffer->end(), "\n"); } FD_ZERO(&rfds); |
