hwatch icon indicating copy to clipboard operation
hwatch copied to clipboard

Long files confuse `hwatch`

Open ilyagr opened this issue 2 years ago • 4 comments

To reproduce: with hwatch 0.3.9 on Linux:

  1. Download qq.tar.gz and unpack it. Update: I reuploaded the file, the previous one had an insane path inside the tar file

  2. Run hwatch cat qq or HWATCH= hwatch cat qq

On my machine, this causes hwatch freeze and no part of the file is ever printed. The file has color sequences in it; hwatch --color cat qq also freezes. less -R qq and watch --color cat qq work with no problems.

For illustration, here's the end of the file in less -R: image

The file is obtained with jj log which is equivalent to git log. I usually use hwatch with jj log with no problems, but for this particular state of the repo something went wrong.

I may or may not try to investigate this myself in the near future.

ilyagr avatar Feb 03 '23 02:02 ilyagr

I think I figured out the cause. The file is simply too long.

$ hwatch "head -n 500 qq"   # Works
$ hwatch "head -n 700 qq"   # Does not work

I think this should still be tracked as a bug. hwatch should handle large file, at least by failing gracefully or cutting them off when a file is too long.

ilyagr avatar Feb 03 '23 04:02 ilyagr

Thanks!

I think this should still be tracked as a bug. hwatch should handle large file, at least by failing gracefully or cutting them off when a file is too long.

That's certainly true. I'll try to figure out how to fix it.

blacknon avatar Feb 03 '23 04:02 blacknon

It certainly doesn't move... In version 0.3.11, I tried to cat the output of git log --color=always and git log (3000 lines), but it doesn't seem to be working.

It stopped outputting after about 2487 lines, so there may be a problem with writing to memory. I'm suspecting the size of Buffer.

blacknon avatar Mar 04 '24 23:03 blacknon

I think this process is probably the cause.

https://github.com/blacknon/hwatch/blob/6695b35046eb3dc662bc6aa2b039e2bd18037f16/src/exec.rs#L99-L115

blacknon avatar Mar 05 '24 15:03 blacknon

Closed because it was applied in version 0.3.12. Thank you for issue!

blacknon avatar Apr 07 '24 07:04 blacknon

It works beautifully now. No more need to add | head -n 300 to every command. Thank you!

ilyagr avatar Apr 09 '24 01:04 ilyagr