Merge remote-tracking branch 'eraserhd/fifo-fixes'
This commit is contained in:
commit
adf77c3e1d
|
@ -129,17 +129,18 @@ Buffer* create_fifo_buffer(String name, int fd, Buffer::Flags flags, bool scroll
|
||||||
// iteration number allows us to go back go back to the event loop and
|
// iteration number allows us to go back go back to the event loop and
|
||||||
// handle other events sources (such as input)
|
// handle other events sources (such as input)
|
||||||
constexpr size_t max_loop = 16;
|
constexpr size_t max_loop = 16;
|
||||||
|
bool closed = false;
|
||||||
size_t loop = 0;
|
size_t loop = 0;
|
||||||
char data[buffer_size];
|
char data[buffer_size];
|
||||||
BufferCoord insert_coord;
|
BufferCoord insert_coord = buffer->back_coord();
|
||||||
const int fifo = watcher.fd();
|
const int fifo = watcher.fd();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
const ssize_t count = ::read(fifo, data, buffer_size);
|
const ssize_t count = ::read(fifo, data, buffer_size);
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
{
|
{
|
||||||
buffer->values().erase(fifo_watcher_id); // will delete this
|
closed = true;
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pos = buffer->back_coord();
|
auto pos = buffer->back_coord();
|
||||||
|
@ -147,8 +148,6 @@ Buffer* create_fifo_buffer(String name, int fd, Buffer::Flags flags, bool scroll
|
||||||
if (prevent_scrolling)
|
if (prevent_scrolling)
|
||||||
pos = buffer->next(pos);
|
pos = buffer->next(pos);
|
||||||
|
|
||||||
if (loop == 0)
|
|
||||||
insert_coord = pos;
|
|
||||||
buffer->insert(pos, StringView(data, data+count));
|
buffer->insert(pos, StringView(data, data+count));
|
||||||
|
|
||||||
if (prevent_scrolling)
|
if (prevent_scrolling)
|
||||||
|
@ -162,8 +161,14 @@ Buffer* create_fifo_buffer(String name, int fd, Buffer::Flags flags, bool scroll
|
||||||
}
|
}
|
||||||
while (++loop < max_loop and fd_readable(fifo));
|
while (++loop < max_loop and fd_readable(fifo));
|
||||||
|
|
||||||
|
if (insert_coord != buffer->back_coord())
|
||||||
|
{
|
||||||
buffer->run_hook_in_own_context(Hook::BufReadFifo,
|
buffer->run_hook_in_own_context(Hook::BufReadFifo,
|
||||||
selection_to_string({insert_coord, buffer->back_coord()}));
|
selection_to_string({insert_coord, buffer->back_coord()}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (closed)
|
||||||
|
buffer->values().erase(fifo_watcher_id); // will delete this
|
||||||
}), std::move(watcher_deleter));
|
}), std::move(watcher_deleter));
|
||||||
|
|
||||||
buffer->values()[fifo_watcher_id] = Value(std::move(watcher));
|
buffer->values()[fifo_watcher_id] = Value(std::move(watcher));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user