Skip to content

Route nested completion after any whitespace - #2137

Open
FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix-nested-whitespace-completion-20261012
Open

FanWu-ai wants to merge 1 commit into
prompt-toolkit:mainfrom
FanWu-ai:fix-nested-whitespace-completion-20261012

Conversation

@FanWu-ai

Copy link
Copy Markdown

NestedCompleter uses whitespace-aware splitting and trimming, but only enters its nested-routing branch when it finds an ASCII space. show\t and show\n therefore suggest root commands instead of child commands; partial nested words and deeper levels fail too.

Recognize whitespace with str.isspace() in that guard, leaving key matching, child completers and cursor offsets unchanged. Add 29 cases for ASCII/Unicode separators, leading whitespace, partial words, cursor suffixes, unknown/terminal commands and multiple levels.

This is independent of #2120's case-insensitive key lookup, which leaves the separator guard unchanged. All new routing examples use exact-case command names.

Validation on Linux / Python 3.12.14:

  • Fresh pristine complete suite: 156 passed; final complete suite: 185 passed, no skips. Twenty-one regressions fail on unchanged source, with eight controls passing.
  • Ruff/format/typos, all three strict Mypy platform checks, all twelve configured pinned hooks, source/wheel builds and strict Twine metadata checks pass. Platform-aware type checks are not native OS test runs.
  • Three real PromptSession Tab-completion flows pass with tab, newline and em-space separators.
  • Independent automated review reran the full suite/static gates and checked 1,798 additional cases spanning all 29 Python whitespace characters and cursor offsets.

Other interpreters/native OS and hosted CI results are not claimed. Prepared and tested with OpenAI Codex assistance; no human review is claimed.

Recognize whitespace consistently with the existing splitter and trimmer,
so tabs and Unicode separators enter the nested completion branch.

AI assistance: OpenAI Codex.
@FanWu-ai
FanWu-ai marked this pull request as ready for review October 11, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant