nushell/crates/nu-parser/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
..
deparse.rs allow empty string arguments (#9420) 2023-06-13 07:30:30 -05:00
flatten.rs Avoid blocking when o+e> redirects too much stderr message (#8784) 2023-05-17 17:47:03 -05:00
known_external.rs Sort entries in scope commands; Fix usage of externs (#10039) 2023-08-17 16:37:01 +02:00
lex.rs Refactor: simplify lex_item impl (#10744) 2023-10-18 23:23:17 +02:00
lib.rs Move SyntaxShape specifier parsing into own file (#10448) 2023-10-05 23:31:40 +02:00
lite_parser.rs redirect should have a target (#10835) 2023-10-25 11:19:35 +02:00
parse_keywords.rs Add special error case for alias (#10975) 2023-11-08 13:35:40 -06:00
parse_patterns.rs add match guards (#9621) 2023-07-16 12:25:12 +12:00
parse_shape_specs.rs Move SyntaxShape specifier parsing into own file (#10448) 2023-10-05 23:31:40 +02:00
parser.rs Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
parser_path.rs Add virtual path abstraction layer (#9245) 2023-05-23 23:48:50 +03:00
type_check.rs Relax type-check of key-less table/record (#10629) 2023-10-08 13:26:36 +02:00