2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-04-20 04:23:23 +00:00

fix: set autoflush to true by default for sinks, and flush when reading from sinks (closes #344)

This commit is contained in:
sammyette 2025-04-17 22:33:50 -04:00
parent 60edfc00ee
commit f64229b52c
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD

View File

@ -94,6 +94,11 @@ func luaSinkReadAll(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
return nil, err
}
if s.autoFlush {
println("flushing the toilet")
s.Rw.Flush()
}
lines := []string{}
for {
line, err := s.Rw.ReadString('\n')
@ -227,6 +232,7 @@ func luaSinkAutoFlush(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
func NewSink(rtm *rt.Runtime, Rw io.ReadWriter) *Sink {
s := &Sink{
Rw: bufio.NewReadWriter(bufio.NewReader(Rw), bufio.NewWriter(Rw)),
autoFlush: true,
}
s.UserData = sinkUserData(rtm, s)