Open lilyball opened 4 years ago
Right... we can't fseek
a pipe.
Currently things work by seeking each line in the window projected over the file. That's how XXV can navigate anywhere in arbitrarily large files.
For something like stdin
, we can't navigate and new data can come along all the time. Would it be reasonable to funnel the data to a temporary file in a background thread, and then place the normal view on that file?
At a bare minimum, we shouldn't panic in a way that puts the terminal in a bad state. The minimal fix here is detecting that the file is a pipe and gracefully erroring.
But yes, I think a better long-term fix is to funnel the data into a temporary file and seek on that. I'd say maybe seeking on a memory buffer except then you have to deal with dumping it to disk once it gets sufficiently large, so maybe just using a temporary file always is a good idea.
If I pass
xxv
a fifo or a named pipe (such as/dev/stdin
) it promptly panics, leaving my terminal in a bad state.