nushell/crates/nu-cli/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
..
commands Add long options for platform and random (#10776) 2023-10-19 22:04:33 +02:00
completions Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
menus Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
config_files.rs Fix config creation during printing (#9353) 2023-06-04 22:04:28 +03:00
eval_cmds.rs Refactor and fix Config<->Value mechanism (#10896) 2023-11-08 20:31:30 +01:00
eval_file.rs Refactor and fix Config<->Value mechanism (#10896) 2023-11-08 20:31:30 +01:00
lib.rs cratification: move the bytes command to nu-cmd-extra (#9509) 2023-06-23 12:23:08 -07:00
nu_highlight.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
print.rs allow print to take data as input again (#9823) 2023-07-27 21:40:25 +02:00
prompt_update.rs Use Vec for Closure captures (#10940) 2023-11-08 00:43:28 +01:00
prompt.rs Fix default prompt indicators (#9914) 2023-08-05 04:47:46 +12:00
reedline_config.rs Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
repl.rs Refactor and fix Config<->Value mechanism (#10896) 2023-11-08 20:31:30 +01:00
syntax_highlight.rs Use slices directly instead of &Vec (#10328) 2023-09-12 11:38:20 +08:00
util.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
validation.rs Remove old alias implementation (#8797) 2023-04-07 21:09:38 +03:00