nushell/crates/nu-cli/src
Yash Thakur 5c2bcd068b
Enable exact match behavior for any path with slashes (#15458)
# Description

Closes #14794. This PR enables the strict exact match behavior requested
in #13204 and #14794 for any path containing a slash (#13302 implemented
this for paths ending in slashes).

If any of the components along the way *don't* exactly match a
directory, then the next components will use the old Fish-like
completion behavior rather than the strict behavior.

This change only affects those using prefix matching. Fuzzy matching
remains unaffected.

# User-Facing Changes

Suppose you have the following directory structure:
```
- foo
  - bar
    - xyzzy
  - barbaz
    - xyzzy
- foobar
  - bar
    - xyzzy
  - barbaz
    - xyzzy
```

- If you type `cd foo<TAB>`, you will be suggested `[foo, foobar]`
- This is because `foo` is the last component of the path, so the strict
behavior isn't activated
  - Similarly, `foo/bar` will show you `[foo/bar, foo/barbaz]`
- If you type `foo/bar/x`, you will be suggested `[foo/bar/xyzzy]`
  - This is because `foo` and `bar` both exactly matched a directory
- If you type `foo/b/x`, you will be suggested `[foo/bar/xyzzy,
foo/barbaz/xyzzy]`
- This is because `foo` matches a directory exactly, so `foobar/*` won't
be suggested, but `b` doesn't exactly match a directory, so both `bar`
and `barbaz` are suggested
- If you type `f/b/x`, you will be suggested all four of the `xyzzy`
files above
- If you type `f/bar/x`, you will be suggested all four of the `xyzzy`
files above
- Since `f` doesn't exactly match a directory, every component after it
won't use the strict matching behavior (even though `bar` exactly
matches a directory)

# Tests + Formatting

# After Submitting

This is a pretty minor change but should be mentioned somewhere in the
release notes in case it surprises someone.

---------

Co-authored-by: 132ikl <132@ikl.sh>
2025-03-31 14:19:09 -04:00
..
commands refactor: rename subcommand structs (#15309) 2025-03-14 02:00:35 +01:00
completions Enable exact match behavior for any path with slashes (#15458) 2025-03-31 14:19:09 -04:00
menus Replace raw usize IDs with new types (#13832) 2024-09-30 13:20:15 +02:00
config_files.rs Refactor I/O Errors (#14927) 2025-01-28 16:03:31 -06:00
eval_cmds.rs Convert Path to list in main and preserve case (#14764) 2025-01-10 10:18:44 -06:00
eval_file.rs More precise ErrorKind::NotFound errors (#15149) 2025-02-22 11:42:44 -05:00
lib.rs Set current working directory at startup (#12953) 2024-09-25 13:04:26 -05:00
nu_highlight.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
print.rs Rely on display_output hook for formatting values from evaluations (#14361) 2024-11-19 21:04:29 +08:00
prompt_update.rs stop the prompt from removing the last newline (#14590) 2025-01-02 09:48:35 -06:00
prompt.rs Make get_env_var return a reference to a Value (#13987) 2024-10-02 13:05:48 +02:00
reedline_config.rs update reedline editcommands in nushell (#15191) 2025-02-28 17:41:27 +01:00
repl.rs fix(nu-command): support ACL, SELinux, e.g. in cd have_permission check (#15360) 2025-03-27 14:23:41 +01:00
syntax_highlight.rs Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
util.rs fix(completion): DotNuCompletion now completes nu scripts in const $NU_LIB_DIRS (#14955) 2025-01-29 05:54:12 -06:00
validation.rs Remove old alias implementation (#8797) 2023-04-07 21:09:38 +03:00