nushell/crates/nu-cli
Yash Thakur 22a01d7e76
Use single atom for fuzzy matching (fix #14904) (#14913)
# Description

Closes #14904. The bug there was introduced by #14846, which replaced
skim with Nucleo. It turns out that Nucleo's `Pattern::new` function
doesn't treat the needle as a single atom - it splits on spaces and
makes each word its own atom. This PR fixes the problem by creating a
single `Atom` for the whole needle rather than creating a `Pattern`.

Because of the bug, when you typed `lines <TAB>` (with a space at the
end), the suggestion `lines` was also matched. This suggestion was
shorter than the original typed needle, which would cause an
out-of-bounds error.

This also meant that if you typed `foo bar<TAB>`, `foo aaaaa bar` would
be shown before `foo bar aaa`. At the time, I didn't realize that it was
more intuitive to have `foo bar aaa` be put first.

# User-Facing Changes

Typing something like `lines <TAB>` should no longer cause a panic.

# Tests + Formatting

- Added a test to ensure spaces are respected when fuzzy matching
- Updated a test with the changed sort order for subcommand suggestions

# After Submitting

No need to update docs.
2025-01-25 08:12:47 -06:00
..
src Use single atom for fuzzy matching (fix #14904) (#14913) 2025-01-25 08:12:47 -06:00
tests Use single atom for fuzzy matching (fix #14904) (#14913) 2025-01-25 08:12:47 -06:00
Cargo.toml Use nucleo instead of skim for completions (#14846) 2025-01-17 06:24:00 -06:00
LICENSE Fix rest of license year ranges (#8727) 2023-04-04 09:03:29 +12:00
README.md Add top-level crate documentation/READMEs (#12907) 2024-07-14 10:10:41 +02:00

This crate implements the core functionality of the interactive Nushell REPL and interfaces with reedline. Currently implements the syntax highlighting and completions logic. Furthermore includes a few commands that are specific to reedline

Internal Nushell crate

This crate implements components of Nushell and is not designed to support plugin authors or other users directly.