fix(editor): keep Ctrl+Space autocomplete open while typing#40
Conversation
…rt mid-word trigger Convert ctrlSpaceOpenRef from a ref to state so toggling it triggers re-renders and recomputes filtered suggestions. When the user explicitly opens autocomplete via Ctrl+Space, position-based filtering is bypassed so all suggestions are available for fuzzy matching against the word at the cursor. The completer stays open while typing and only closes on space, newline, Escape, or accepting a completion.
| // When user explicitly triggered autocomplete (Ctrl+Space), skip | ||
| // position-based filtering so all suggestions are available for | ||
| // fuzzy matching against the word at the cursor. | ||
| if (!ctrlSpaceOpen) { |
There was a problem hiding this comment.
this if statement is wrong IMO isn't it?
Note - that - columns suggestions are available only when you made first query.
There was a problem hiding this comment.
On my play testing - looks like without this if statement - it works without the bug - and with the intended improvement of always forcing auto complete.
maybe in this case we will should "no results" if user tries to autocomplete - and there are no results?
WDYT?
There was a problem hiding this comment.
it doesnt work as expected without the if statement. but you are right about the bug.
changed it a bit. lmk what you think
There was a problem hiding this comment.
What exactly the behaviour you expect?
we might look at things differently
…nly when needed Use smart contextual suggestions when the parser provides position matches. Only broaden to all suggestions when Ctrl+Space is active and no position-based suggestions cover the cursor.
|
looks like when there's no columns yet (before quering it still suggests other commands) |
| // Use position-filtered (smart) suggestions when available. | ||
| // Fall back to all suggestions only when Ctrl+Space is active | ||
| // and no position-based suggestions match the cursor. | ||
| const candidates = | ||
| positionFiltered.size > 0 || !ctrlSpaceOpen | ||
| ? positionFiltered | ||
| : allDeduped; |
There was a problem hiding this comment.
this one just should be:
const candidates = positionFiltered
what's the purpose of allDeduped?
There was a problem hiding this comment.
for mid word autocomplete. it wont work if const candidates = positionFiltered
There was a problem hiding this comment.
for me it does work 🤔 are you sure?
|
@IamShobe ok the "table" case is fixed. |
|
Looks amazing 🤩 |





Summary
ctrlSpaceOpenReffrom a ref to state so toggling it triggers re-renders and recomputes filtered suggestionsTest plan