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:
parent
60edfc00ee
commit
f64229b52c
@ -94,6 +94,11 @@ func luaSinkReadAll(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.autoFlush {
|
||||||
|
println("flushing the toilet")
|
||||||
|
s.Rw.Flush()
|
||||||
|
}
|
||||||
|
|
||||||
lines := []string{}
|
lines := []string{}
|
||||||
for {
|
for {
|
||||||
line, err := s.Rw.ReadString('\n')
|
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 {
|
func NewSink(rtm *rt.Runtime, Rw io.ReadWriter) *Sink {
|
||||||
s := &Sink{
|
s := &Sink{
|
||||||
Rw: bufio.NewReadWriter(bufio.NewReader(Rw), bufio.NewWriter(Rw)),
|
Rw: bufio.NewReadWriter(bufio.NewReader(Rw), bufio.NewWriter(Rw)),
|
||||||
|
autoFlush: true,
|
||||||
}
|
}
|
||||||
s.UserData = sinkUserData(rtm, s)
|
s.UserData = sinkUserData(rtm, s)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user