fix(loop): fix stopping and starting of loop

When stopping the loop, we never reset `should_quit` which caused the
program to not read any input if the loop were started again
This commit is contained in:
Tim Culverhouse 2024-06-03 07:36:12 -05:00
parent 052ff24c2f
commit 84cd9fdebe

View file

@ -50,7 +50,7 @@ pub fn Loop(comptime T: type) type {
}); });
} }
/// stops reading from the tty and returns it to it's initial state /// stops reading from the tty.
pub fn stop(self: *Self) void { pub fn stop(self: *Self) void {
self.should_quit = true; self.should_quit = true;
// trigger a read // trigger a read
@ -59,6 +59,7 @@ pub fn Loop(comptime T: type) type {
if (self.thread) |thread| { if (self.thread) |thread| {
thread.join(); thread.join();
self.thread = null; self.thread = null;
self.should_quit = false;
} }
} }