Fix autocomplete targeting between mentions#30463
Draft
charliemarsh-oai wants to merge 4 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the cursor is on separator whitespace between an unbound skill mention and an already bound mention, we previously preferred the token to the right. For example, with
|representing the cursor:The popup should target
$unbound-skill, but it could instead resolve$bound-skill, whose text is already an atomic element. The insertion paths also rediscovered token boundaries independently, which made it possible for lookup and replacement to disagree.The token lookup now returns the editable token's byte range, and the skill, file, and image insertion paths consume that range directly. This replaces exactly the token that opened the popup while preserving neighboring mention bindings and text elements.
When completion reuses existing whitespace, we also place the cursor after the separator:
This prevents subsequent typing from producing
$unbound-skillfoo .... The full chat-composer test suite passes.