Skip to content

Editor: autocomplete items don't expand snippets #79

Description

@KrisPowers

The autocomplete popup can show completion items, but when a completion is accepted, only the plain label text is inserted. Items that should expand into a snippet (for example, a function call that fills in its parameter placeholders, or a for-loop template) just insert the raw name instead.

This means accepting a completion for something like useEffect inserts only useEffect rather than useEffect(() => {\n \n}, []) with tab stops.

What needs to happen

  • The completion item format returned from the backend should support an optional snippet body separate from the display label.
  • Snippet bodies use tab stop markers (e.g., $1, $2, $0 for final cursor) in VS Code / LSP snippet format.
  • When a snippet completion is accepted, insert the body text and place the cursor at $1. Tab moves to $2, and so on. Escape or any non-tab editing key exits snippet mode.
  • For completions that are just plain identifiers (no snippet), behavior stays exactly the same as today.

Files likely involved

  • app/frontend/src/components/GpuEditor.tsx -- completion acceptance logic and snippet tab-stop state machine
  • app/frontend/src/components/CompletionsPopup.tsx (or wherever the popup renders)
  • Backend completion provider would need to send snippet bodies alongside completion labels

Acceptance criteria

  • Accepting a snippet completion inserts the body with cursor at the first tab stop
  • Tab moves between tab stops in order
  • Pressing Escape or typing outside a tab stop exits snippet mode and leaves the inserted text in place
  • Plain completions (no snippet) are unaffected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions