Description
Describe the bug
When we have multiple files whose names
- Have a space character (0x20)
- Have a non-ASCII character before that space
- Start with the same substring
It is possible to cause a panic when autocompleting the file name
A very practical example - when having two files called Лекція 1.docx
and Лекція 2.docx
in the same directory, trying any of the following autocompletes causes a panic: ls Л<Tab>
ls Ле<Tab>
... ls Лекція<Tab>
(using ls
is purely demonstrative, autocompleting in any context causes a panic)
Curiously enough, the panic happens only when the last character of user's prefix is non-ASCII - for two files ТестTest 1
and ТестTest 2
, autocompleting ls Те<Tab>
panics, but ls ТестTes<Tab>
does not
This does not happen if you autocomplete with quotes: ls "Лекц<Tab>"
does not cause a panic
The text of the panic itself (after attempting ls При<Tab>
) (also occasionally the panic is only seen for a second and then disappears, can't pinpoint why):
× Main thread panicked.
├─▶ at /usr/src/debug/rust/rustc-1.84.1-src/library/core/src/str/
│ mod.rs:648:21
╰─▶ byte index 6 is not a char boundary; it is inside 'и' (bytes 5..7) of
``Пример 1``
How to reproduce
Here is a script generating useful examples
mkdir example
cd example
touch "Пример 1" "Пример 2" # Example
touch "例 1" "例 2" # Example
touch "gggффф 1" "gggффф 2" # ASCII then Unicode
touch "фффggg 1" "фффggg 2" # Unicode then ASCII
touch "один файл" # This one works correctly
- Run the script
- (Optionally) enter the directory (works either way, just prepend
example/
in examples below) - Try performing following autocompletes:
ls один<Tab> # this one works
ls При<Tab>
ls Пример<Tab>
ls 例<Tab>
ls g<Tab> # this one works
ls ggg<Tab> # this also works
ls gggф<Tab>
ls gggффф<Tab>
ls ф<Tab>
ls фффg<Tab> # this one works (curiously)
Expected behavior
No panic
Configuration
key | value |
---|---|
version | 0.102.0 |
major | 0 |
minor | 102 |
patch | 0 |
branch | makepkg |
commit_hash | 1aa2ed1 |
build_os | linux-x86_64 |
build_target | x86_64-unknown-linux-gnu |
rust_version | rustc 1.84.1 (e71f9a9a9 2025-01-27) (Arch Linux rust 1:1.84.1-1) |
cargo_version | cargo 1.84.1 (66221abde 2024-11-19) |
build_time | 2025-02-05 21:56:07 +00:00 |
build_rust_channel | release |
allocator | mimalloc |
features | default, sqlite, trash |
installed_plugins |
Activity
blindFS commentedon Mar 12, 2025
Should be fixed by this nushell/reedline#886, which is not yet merged.
ysthakur commentedon Jun 21, 2025
This should be fixed by nushell/reedline#886 (prefix matching) and nushell/reedline#918 (fuzzy matching)
related: #11916