nushell/crates/nu-command/src
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
..
bytes Convert ShellError::UnsupportedInput to named fields (#10971) 2023-11-07 23:25:32 +01:00
charting Use Vec for Closure captures (#10940) 2023-11-08 00:43:28 +01:00
conversions Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
database Use Record's public API in a bunch of places (#10927) 2023-11-08 14:24:00 +01:00
date Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
debug Use Record::get instead of Value functions (#10925) 2023-11-08 21:47:37 +01:00
env Use Vec for Closure captures (#10940) 2023-11-08 00:43:28 +01:00
experimental Add functions for each Value case (#9736) 2023-07-21 08:20:33 -05:00
filesystem Add umkdir command (#10785) 2023-10-30 07:59:48 -05:00
filters Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
formats Use record API in more parts of nu-protocol (#10928) 2023-11-08 23:03:08 +01:00
generators Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
hash Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
help Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
math Convert ShellError::UnsupportedInput to named fields (#10971) 2023-11-07 23:25:32 +01:00
misc Add long options for misc and network (#10753) 2023-10-19 18:16:44 +02:00
network Use Record's public API in a bunch of places (#10927) 2023-11-08 14:24:00 +01:00
path Convert ShellError::UnsupportedInput to named fields (#10971) 2023-11-07 23:25:32 +01:00
platform Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
random Add long options for platform and random (#10776) 2023-10-19 22:04:33 +02:00
removed Rename misused "deprecation" to removal (#10000) 2023-08-15 07:17:31 +12:00
shells Fix usage for the exit command. (#9450) 2023-06-16 10:09:02 +02:00
strings Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
system Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
viewers Use record API in more parts of nu-protocol (#10928) 2023-11-08 23:03:08 +01:00
default_context.rs Add exec command for Windows (#11001) 2023-11-08 14:50:25 -06:00
example_test.rs feat: Add unfold command (#10489) 2023-09-30 09:08:06 -05:00
lib.rs Move eval_hook to nu-cmd-base (#10146) 2023-08-29 23:46:50 +02:00
progress_bar.rs cp progress bar implementation (#8012) 2023-02-22 11:57:38 -08:00
sort_utils.rs Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00