Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocompleting specifically named files causes panic (utf8-related) #15302

Open
KittenLord opened this issue Mar 12, 2025 · 1 comment
Open
Labels
needs-triage An issue that hasn't had any proper look

Comments

@KittenLord
Copy link

KittenLord commented Mar 12, 2025

Describe the bug

When we have multiple files whose names

  1. Have a space character (0x20)
  2. Have a non-ASCII character before that space
  3. 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
  1. Run the script
  2. (Optionally) enter the directory (works either way, just prepend example/ in examples below)
  3. 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
@KittenLord KittenLord added the needs-triage An issue that hasn't had any proper look label Mar 12, 2025
@blindFS
Copy link
Contributor

blindFS commented Mar 12, 2025

Should be fixed by this nushell/reedline#886, which is not yet merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage An issue that hasn't had any proper look
Projects
None yet
Development

No branches or pull requests

2 participants