Skip to content

fix(completion): apostrophes in prose no longer hide later @file refs - #916

Open
12britz wants to merge 1 commit into
mpfaffenberger:mainfrom
12britz:fix/915-contraction-quotes
Open

fix(completion): apostrophes in prose no longer hide later @file refs#916
12britz wants to merge 1 commit into
mpfaffenberger:mainfrom
12britz:fix/915-contraction-quotes

Conversation

@12britz

@12britz 12britz commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #915

Summary

Since 029ca24, an apostrophe anywhere in the prompt could disable later @file completion: don't change @target offered no candidates while read @target worked. active_reference() treated every '/" in the prompt as a quote delimiter, so the contraction opened quote state, subsequent whitespace stopped advancing the active-token boundary, and the later @token was never recognized.

Fix

A quote character now opens a quoted span only where a filename is legitimately quoted:

  • at a word boundary (start of input or right after whitespace), or
  • immediately following the attachment symbol (@"my file)

A quote embedded inside a word — the apostrophe in don't, it's — is ordinary prose and never opens quote state.

Quoted/escaped path semantics from 029ca24 are preserved: @"my file.txt, @'my file, @my\ file.txt still complete, and @"my file.txt" done still returns no active reference so trailing prose is never replaced.

Also fixes a failing test on main

tests/test_completions_and_small_modules.py::TestFilePathCompleterMissedLines::test_tilde_prefix_display currently fails on main: it asserts insertion text starts with ~, but 029ca24 quotes inserted paths via shlex.quote (its own regression test asserts shlex.split(inserted) parses back). Updated it to decode via shlex.split before asserting the tilde-prefixed path.

Test plan

  • New regression cases in tests/command_line/test_file_completion_regressions.py: contractions before @file (don't, it's, can't, they're, isn't), quote grouping, closed-quote suppression
  • uv run pytest tests/command_line/ tests/messaging/test_completion_stable_popup.py tests/messaging/test_editor_completion.py tests/plugins/test_completion_provider.py tests/test_completions_and_small_modules.py — 1062 passed
  • ruff check + ruff format clean

active_reference treated every quote character in the prompt as a
delimiter, so the apostrophe in contractions like "don't" opened quote
state, swallowed subsequent whitespace, and left later @tokens
unrecognized (issue mpfaffenberger#915). Quotes now only open a quoted span at a word
boundary or immediately after the attachment symbol — the two places a
filename is legitimately quoted. Quoted/escaped paths and closed-quote
suppression keep their 029ca24 semantics.

Also updates test_tilde_prefix_display, which still asserted unquoted
insertion text and failed on main since 029ca24 quotes paths via
shlex.quote.

Fixes mpfaffenberger#915

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@breedx

breedx commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for picking up #915! I confirmed that 38d3ba7 fixes the contractions from our report. The two changed test files pass locally (57 tests), and Ruff lint/format checks pass for all three changed files.

I found one compatibility regression worth addressing before merge: the new quote-opening restriction also applies inside an active attachment path. With dir/my file.txt present and the cursor at the end:

  • @dir/"my fi offered a completion before this patch but now returns no candidates.
  • @dir/'my fi likewise worked before and now returns no candidates.
  • @"dir/my fi and @dir/my\ fi still work.

I reproduced this through the real FilePathCompleter.get_completions with temporary files and background indexing disabled, swapping only active_reference between base 1d25d696 and head 38d3ba76. The base parser returns ("dir/my fi", 10) for both partially quoted inputs; the PR parser returns None. The _opens_quote guard ignores the quote after /, so the following space advances the token boundary past the attachment.

Could we preserve shell-style quote handling within an active attachment token while ignoring apostrophes in preceding prose, and add both partially quoted path cases to the regression tests? The contraction fix itself is working; this is a narrow compatibility edge to retain alongside it.

Validation was on Linux through parser/completer calls and the focused tests, not a full interactive TUI run.

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.

Regression: apostrophes in prompt prose disable subsequent @file completion

2 participants