1
1
mirror of https://github.com/walles/moar.git synced 2024-09-21 17:08:34 +03:00

Mark string readers complete from the start

Related to #31.

Before this change, string readers always rendered as in-progress.

With this change in place, they instead always render as complete.
This commit is contained in:
Johan Walles 2020-12-28 18:44:04 +01:00
parent eace381664
commit 17ac7e8e62

View File

@ -177,10 +177,13 @@ func NewReaderFromStream(reader io.Reader, fromFilter *exec.Cmd) *Reader {
// NewReaderFromText creates a Reader from a block of text
func NewReaderFromText(name string, text string) *Reader {
noExternalNewlines := strings.Trim(text, "\n")
done := make(chan bool, 1)
done <- true
return &Reader{
name: &name,
lines: strings.Split(noExternalNewlines, "\n"),
lock: &sync.Mutex{},
done: done,
}
}