opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(tui): reopen autocomplete after backspace deletes space

Open Raviguntakala opened this issue 2 months ago • 3 comments

Problem

When typing / or @, autocomplete shows suggestions.
If you press space by mistake, the dropdown closes.
When you press backspace to remove the space, autocomplete does not come back, even though the text is valid again.

Steps to Reproduce

  1. Type /something → autocomplete appears
  2. Press space → autocomplete closes
  3. Press backspace → autocomplete does not reopen

Fix

Updated the onInput logic to reopen autocomplete when the cursor is back in a valid position.

  • For /
    Autocomplete reopens when the text starts with / and there is no space before the cursor

  • For @
    Finds the closest @ before the cursor and reopens autocomplete if there is no space between @ and the cursor

Testing

  • /something → space → backspace → autocomplete reopens
  • @agent → space → backspace → autocomplete reopens
  • Normal behavior is unchanged
  • Text like test/path does not trigger / autocomplete

https://github.com/user-attachments/assets/37d91fa1-2af7-466a-8981-fd5d31ec21c9

https://github.com/user-attachments/assets/a37e46dd-e74b-4bec-94e0-fb390625847a

Raviguntakala avatar Dec 23 '25 11:12 Raviguntakala

Hey @rekram1-node , just a quick ping to check this PR when you have time. Thanks!

Raviguntakala avatar Dec 27 '25 16:12 Raviguntakala

Does it work with CJK characters before and in the @ part?

kommander avatar Jan 09 '26 15:01 kommander

Does it work with CJK characters before and in the @ part?

Yes, I tested with CJK characters before and in the @ trigger. Autocomplete opens correctly, cursor positioning is fine, and behavior is consistent.

The screenshots show:

1.你好 @ (Chinese: "Hello @") image 2.こんにちは@ (Japanese: "Hello @") image 3.你好 @to (Chinese text before @, then filtering) image 4.안녕하세요 @file (Korean: "Hello @file") image 5.test 你好 @ (English + Chinese mixed) image

Raviguntakala avatar Jan 09 '26 18:01 Raviguntakala

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

github-actions[bot] avatar Jan 12 '26 18:01 github-actions[bot]

/review

rekram1-node avatar Jan 12 '26 18:01 rekram1-node

lgtm

github-actions[bot] avatar Jan 12 '26 18:01 github-actions[bot]