nushell/crates/nu-command/src/platform
Christopher Durham 0f600bc3f5
Improve case insensitivity consistency (#10884)
# Description

Add an extension trait `IgnoreCaseExt` to nu_utils which adds some case
insensitivity helpers, and use them throughout nu to improve the
handling of case insensitivity. Proper case folding is done via unicase,
which is already a dependency via mime_guess from nu-command.

In actuality a lot of code still does `to_lowercase`, because unicase
only provides immediate comparison and doesn't expose a `to_folded_case`
yet. And since we do a lot of `contains`/`starts_with`/`ends_with`, it's
not sufficient to just have `eq_ignore_case`. But if we get access in
the future, this makes us ready to use it with a change in one place.

Plus, it's clearer what the purpose is at the call site to call
`to_folded_case` instead of `to_lowercase` if it's exclusively for the
purpose of case insensitive comparison, even if it just does
`to_lowercase` still.

# User-Facing Changes

- Some commands that were supposed to be case insensitive remained only
insensitive to ASCII case (a-z), and now are case insensitive w.r.t.
non-ASCII characters as well.

# Tests + Formatting

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2023-11-08 23:58:54 +01:00
..
ansi Move ansi link from extra to default feature, close #10792 (#10801) 2023-10-21 11:04:37 -05:00
input Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
clear.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
dir_info.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
du.rs Allow filesystem commands to access files with glob metachars in name (#10694) 2023-10-18 13:31:15 -05:00
kill.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
mod.rs implement whoami using uutils (#10488) 2023-10-25 09:53:52 -05:00
sleep.rs return error when user break sleep by ctrl-c (#10234) 2023-09-05 09:21:30 -05:00
term_size.rs Create Record type (#10103) 2023-08-25 07:50:29 +12:00
whoami.rs implement whoami using uutils (#10488) 2023-10-25 09:53:52 -05:00