fix: Panic on long numerical file names

Closes: #258

[lexical_sort](https://github.com/Aloso/lexical-sort) is currently
unmaintained. The author recommends switching to the `icu` crate which
is maintained by the Unicode Consortium.
This commit is contained in:
Josh Megnauth 2024-07-08 02:00:52 -04:00
parent 5ec14f86b3
commit 783256fe8b
No known key found for this signature in database
GPG key ID: 70813183462EFAD3
6 changed files with 622 additions and 28 deletions

View file

@ -41,6 +41,7 @@ use std::{
time::{self, Instant},
};
use crate::localize::LANGUAGE_SORTER;
use crate::tab::HOVER_DURATION;
use crate::{
clipboard::{ClipboardCopy, ClipboardKind, ClipboardPaste},
@ -503,7 +504,7 @@ impl App {
}
}
// Sort by name lexically
nav_items.sort_by(|a, b| lexical_sort::natural_lexical_cmp(&a.1.name(), &b.1.name()));
nav_items.sort_by(|a, b| LANGUAGE_SORTER.compare(&a.1.name(), &b.1.name()));
// Add items to nav model
for (key, item) in nav_items {
nav_model = nav_model.insert(|mut b| {
@ -2653,7 +2654,7 @@ pub(crate) mod test_utils {
match (a.is_dir(), b.is_dir()) {
(true, false) => Ordering::Less,
(false, true) => Ordering::Greater,
_ => lexical_sort::natural_lexical_cmp(
_ => LANGUAGE_SORTER.compare(
a.file_name()
.expect("temp entries should have names")
.to_str()