Skip to content

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

Closed
@KittenLord

Description

@KittenLord

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

Activity

blindFS

blindFS commented on Mar 12, 2025

@blindFS
Contributor

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

added
🐛 bugSomething isn't working
completionsIssues related to tab completion
and removed
needs-triageAn issue that hasn't had any proper look
on Mar 13, 2025
ysthakur

ysthakur commented on Jun 21, 2025

@ysthakur
Member

This should be fixed by nushell/reedline#886 (prefix matching) and nushell/reedline#918 (fuzzy matching)

related: #11916

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't workingcompletionsIssues related to tab completionpanic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @blindFS@ysthakur@KittenLord

        Issue actions

          Autocompleting specifically named files causes panic (utf8-related) · Issue #15302 · nushell/nushell