Skip to content

fix(editor): keep Ctrl+Space autocomplete open while typing#40

Merged
IamShobe merged 5 commits into
IamShobe:mainfrom
yarinba:fix/ctrl-space-autocomplete
Mar 14, 2026
Merged

fix(editor): keep Ctrl+Space autocomplete open while typing#40
IamShobe merged 5 commits into
IamShobe:mainfrom
yarinba:fix/ctrl-space-autocomplete

Conversation

@yarinba

@yarinba yarinba commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Convert ctrlSpaceOpenRef from a ref to state so toggling it triggers re-renders and recomputes filtered suggestions
  • When user explicitly opens autocomplete via Ctrl+Space, bypass position-based filtering — all suggestions are available for fuzzy matching against the word at cursor
  • Completer stays open while typing in Ctrl+Space mode; closes on space, newline, Escape, or accepting a completion
  • Fixes: typing "app_c" then Ctrl+Space now shows suggestions like "app_customer_id"

Test plan

  • lint / format / tests / typecheck all pass (CI)
  • Open searcher, press Ctrl+Space on empty editor — autocomplete appears
  • Type characters after Ctrl+Space — autocomplete stays open and filters
  • Type "app_c" then press Ctrl+Space — see matching suggestions like "app_customer_id"
  • Press Escape — autocomplete closes
  • Accept a completion with Tab/Enter — autocomplete closes
  • Type a space — autocomplete closes (exits Ctrl+Space mode)

yarinba added 2 commits March 14, 2026 20:38
…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.
@IamShobe

Copy link
Copy Markdown
Owner

Looks like there's wierd bug - that autocompletes wrong phrases now 🤔
image
After table we shouldn't suggest table 🤔
checking it

// 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) {

@IamShobe IamShobe Mar 14, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this if statement is wrong IMO isn't it?

Note - that - columns suggestions are available only when you made first query.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesnt work as expected without the if statement. but you are right about the bug.
changed it a bit. lmk what you think

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly the behaviour you expect?
we might look at things differently

yarinba and others added 2 commits March 14, 2026 23:52
…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.
@IamShobe

Copy link
Copy Markdown
Owner
image

This one is still wrong 🙈, checking what's the issue

@IamShobe

Copy link
Copy Markdown
Owner

looks like when there's no columns yet (before quering it still suggests other commands)

Comment on lines +299 to +305
// 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;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one just should be:
const candidates = positionFiltered

what's the purpose of allDeduped?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for mid word autocomplete. it wont work if const candidates = positionFiltered

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for me it does work 🤔 are you sure?

@yarinba

yarinba commented Mar 14, 2026

Copy link
Copy Markdown
Contributor Author
image This one is still wrong 🙈, checking what's the issue

Checking

@yarinba

yarinba commented Mar 14, 2026

Copy link
Copy Markdown
Contributor Author

@IamShobe ok the "table" case is fixed.
for param auto complete:
image

autocomplete after "table" show no results
image

@yarinba
yarinba requested a review from IamShobe March 14, 2026 22:39
@IamShobe

Copy link
Copy Markdown
Owner

Looks amazing 🤩

@IamShobe IamShobe left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! amazing!

@IamShobe
IamShobe merged commit 0d1de8c into IamShobe:main Mar 14, 2026
4 checks passed
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.

2 participants