Skip to content

[Bug]: Tab completion stops working after completing a directory path containing spaces #26223

@fukumen

Description

@fukumen

Bug Description

When tab-completing a file path in the Hermes CLI, if the completed path contains a space (e.g., My Documents/), subsequent Tab presses no longer show completions for files inside that directory.

Steps to Reproduce

  1. Start Hermes CLI: hermes
  2. Type a partial path to a directory with spaces, e.g., ./My
  3. Press Tab → completes to My Documents/
  4. Press Tab again (or type a character and press Tab)
  5. Expected: Show files inside My Documents/
  6. Actual: No completions shown

Root Cause

_extract_path_word() in hermes_cli/commands.py walks backwards from the cursor,
stopping at the first space character. After My Documents/ is completed, the function
extracts only Documents/ as the "word", which doesn't match any directory in the current
working directory, so no completions are returned.

Affected Component

CLI (interactive chat)

Proposed Fix

In _extract_path_word(), when encountering a space, check if the text after the space
contains a /. If so, the space is part of a path — keep walking backwards instead of
stopping.

# Before
while i >= 0 and text[i] != " ":
    i -= 1

# After
while i >= 0:
    if text[i] != " ":
        i -= 1
    else:
        rest = text[i + 1:]
        if "/" in rest or rest.startswith("~"):
            i -= 1
        else:
            break

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/cliCLI entry point, hermes_cli/, setup wizardtype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions