File names that start with a number cause a crash
tstack opened this issue · comments
Tim Stack commented
Problem
File names that start with a number seem to cause a problem with the file name sorting done for the UI.
How to reproduce
Create a file that starts with a number, like 1.txt
. Then, run tl
with that file and another one:
tl 1.txt /var/log/system.log
I see a traceback that ends with this:
File "/opt/homebrew/lib/python3.11/site-packages/toolong/ui.py", line 91, in __init__
self.file_paths = self.sort_paths(file_paths)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/toolong/ui.py", line 88, in sort_paths
return sorted(paths, key=key)
^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'int' and 'str'
Details
It looks like the following code is trying to do a natural sort, but doesn't handle all the cases well:
Lines 82 to 86 in 9fe54a6
Will McGugan commented
Thanks. Should be fixed in 1.1.1