Autocompleting the expressions of a snippet

Have this situation.

  • First I autocomplete a snipped : SELECT * FROM ${table}
  • Then table variable is selected, I press my autocomplete keys again to fill it with a second autocompletion (without typing anything in between)

What I want now:

  • all completion sources are NOT filtered by table
  • but inserting the autocompletion should overwrite table

With setting from and to I can only achieve one or the other.
Any hints on how to best achieve both ?

Think I found a solution. If I detect a selected range, I simply set filter to false on the CompletionResults. That way - with from/to set properly - the autocomplete will show every completion without filtering on table but once I start writing the filtering will kick in! Exactly how I want it !

It seems reasonable to replace the entire selection when picking a completion. This patch changes @codemirror/autocomplete to work that way.

1 Like

Hi! Seems it doesn’t work with snippet, that was created with snippetCompletion function. In that case apply is not a string and insertCompletionText is not called. autocomplete/src/state.ts at c323263146e4f8262d59f420256580b25428f276 · codemirror/autocomplete · GitHub

Is there workaround for it?

P.S. may be I should create new topic

This patch should fix that.