moar icon indicating copy to clipboard operation
moar copied to clipboard

`moor` hangs when opening files with extremely long lines

Open apcamargo opened this issue 1 month ago • 4 comments

I tried using moor to open a file containing very long lines (the longest was 248,387,328 characters), and it hung indefinitely. In contrast, less -S opened the file without issues.

I am not sure how less handles such cases so efficiently, but it likely reads only the portion needed to render the current screen and then moves to the next line without fully processing the remainder. At minimum, it must locate the end of each line.

apcamargo avatar Nov 26 '25 20:11 apcamargo

I never tried moor on files with lines that long, I'll see what I can do.

Out of curiosity, what kind of file is that with 250MB long lines?

walles avatar Nov 28 '25 20:11 walles

In this particular case, it was a FASTA file. It's a format that stores DNA or protein sequences. Usually, sequences are broken into multiple lines:

>sequence_1
GTGCAAAAACTGTGTACAAAAGCCCCAAAGTATAATTTGCGCAGTTGAGCACATGTTCTG
TTGTCCAGCATTTATGGTGGTTTGTAGTGGAAAAGATTTTTAGAATATGTGGATTTTTGG
GATATTCCCAGAAGCCCAGATGGCCACACTTTAACTTTGGAGGAATTAATTCTCAGAATA
TTGCACACAATCAATCGCCTTTGGAAGGAGCATATATTCCCAGCAAAAGCTCTGGTTTTT
TGAAGTCTGTGTTGTGTGTTATTTCCAGGAGAATATGCAATGATGACAATGTTATTAACT
GATTCGAATATGAAATGCTGTTATGCCAAACAATGAATCTTTGTGTTACACATTATGCCT
AACTATAAATCTTCGTGTTATACATTTTAATGTCATTGGAGAGTACTCCTGTCTTCTTGG
CATTATTGATAATTCGATTCTAATTGCTAATAAGTCAGAAAAATTAGGAACACCAAATTT
CAGTCGTCTCAAAAGCACTCCTCTTATTAAATTTGGATTTTTACCTTTATCACATCAAAA
GAAATATTGTTAGAAAGGTGTTTAATGTTTTCCAGATGGTTAGATTACTGT
>sequence_2
GAAGGGAGCTGGGAATGAGGGGCCACACAAGCCCGGGACGGAGGCCTGTCGCACATGGGG
TGGCCCCGACTCAGGCCCTGGAGTTGGCCAGGACCCTCTAGCATCCTCAAGGGCTGGGCC
AACCAGGCTGGCATGGGGTGGGGCAGGGGAGGGCTGAGCCAGTGGGCGTCGTCTGTAGGG
GGATGCCCAACTGCGGCCCCGTCTCTCGG

But this is not enforced and it's not uncommon to have the entire sequence in a single line. When your sequence is an entire genome, you end up with an incredibly long line.

apcamargo avatar Nov 28 '25 21:11 apcamargo

So obviously moor should not hang.

What if I put a limit in place so that lines get truncated at 500 characters or so?

How would that work for you?

Not sure what would be the right thing here, just weighing my options.

walles avatar Dec 02 '25 20:12 walles

That could work. Is there a way to determine the number of characters from the terminal width? Just to be sure even more extreme cases are covered.

apcamargo avatar Dec 03 '25 19:12 apcamargo

In v2.9.6, just out, this works less bad.

Not great, but an improvement.

I'll keep this ticket open for now.

walles avatar Dec 17 '25 07:12 walles

Thanks, @walles!

apcamargo avatar Dec 17 '25 12:12 apcamargo