-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: transliteration option for natural sorting #1053
Conversation
c6f0b4c
to
1ba2e8b
Compare
Thank you for the PR! Here's my change request: Since most characters are contiguous, representing them as Rust arrays could avoid parsing while providing lookup efficiency, as they are contiguous in memory: const DICT = [
"A", // À 192
"A", // Á 193
"A", // Â 194
// ...
"h", // ʯ 687
]; I think they can be represented by 3 arrays, À (U+00C0) ~ ʯ (U+02AF):
And, Ḅ (U+1E04 - 7684) ~ ỹ (U+1EF9 - 7929):
fi (U+FB01 - 64257) ~ fl (U+FB02 - 64258):
|
Very good point! Should be an easy enough change on my end. |
Please change it! |
I'll be able to finish the change request in the next day or two. Have not had enough free time the last week. Thanks! |
1ba2e8b
to
84ed30e
Compare
Okay, change request is complete. Transliteration now uses 3 |
84ed30e
to
7849712
Compare
Hi, I've made some simplifications and performance optimizations to the code and reviewed the |
Co-authored-by: sxyazi <sxyazi@gmail.com>
This resolves #616.
To do this, I have a text file of transliteration mappings, which is then initialized into a static
HashMap
only once viaOnceLock
. If we ever need more transliterations added, we just add to thetransliteration.map
file. The actual transliteration is carried out via theTransliterator
trait, which is currently implemented on byte arrays.The user can set the
sort_transliteration
config variables totrue
if they would like to enable transliteration. They currently default tofalse
. This will then apply transliteration to natural sorting only. We can extend transliteration to alphabetical sorting as well, but not sure if that is something you'd want.This also addresses some issues with the sorting keymap commands (they were all forcing
--dir-first
rather than pulling the value from the users config). Additionally, the--reverse
parameter would persist as an override over the users config setting. I.e - If I setreverse = true
in my config, and then I ran the,n
command, it would set myreverse
value tofalse
for the rest of the session and disregard the value in my config.Here are some example screenshots (I know I still need to have some fun and make my theme better...) -
Natural sorting (without transliteration):
Natural sorting (with transliteration):
Please let me know your thoughts. Thanks!