Skip to content

Completion no longer steals Enter after key: - #451

Open
holodorum wants to merge 2 commits into
kson-org:mainfrom
holodorum:worktree-completion-triggers
Open

holodorum wants to merge 2 commits into
kson-org:mainfrom
holodorum:worktree-completion-triggers

Conversation

@holodorum

Copy link
Copy Markdown
Collaborator

The language server asked editors to open completion on :, ,, {, [ and every newline. Those are exactly the spots where the next keystroke is often Enter: an object conventionally nests on the line after key:, and brackets and commas open multi-line structure. With the popup already open, Enter accepted the first suggestion instead of inserting the newline.

What changed

The server now declares ", ', newline and space as trigger characters, and answers the whitespace ones only at an empty slot: after :, ,, { or [, with the rest of the line blank apart from auto-closed brackets. In practice:

Prior art

The YAML language server declares no trigger characters and relies on editor quick suggestions. VS Code's JSON server declares " and :; the colon suits JSON, where the value follows on the same line, but not KSON. TypeScript declares space and decides server-side, which is the pattern used here.

Known gaps

  • A trailing comment after key: suppresses the popup on the next line.
  • A delimiter inside a comment or quoted string, most often a comma and space in comment prose, can still open the popup.

The bridge's completion provider sent only the document and position,
so the server could not tell a typed trigger character from an
explicit invocation. The VS Code client sends that context; the Monaco
bridge now does too, mapping Monaco's zero-based trigger kinds onto
LSP's one-based ones.
The server opened completion on ':', ',', '{', '[' and every newline,
where the next keystroke is often Enter: an object conventionally nests
on the line after `key:`, and brackets and commas open multi-line
structure. With the popup open, Enter accepted a suggestion instead.

Declare '"', "'", '\n' and ' ' as triggers, and answer the whitespace
ones only at an empty slot: after ':', ',', '{' or '[', with the rest
of the line blank but for auto-closed closing brackets. So `status: `
lists its enum values, `server:` then Enter breaks the line and offers
the nested properties on the fresh line, and spacing out `status:active`
stays quiet. Requests without a completion context are always answered.

Known gaps: a trailing comment after `key:` suppresses the popup, and
a delimiter inside a comment or quoted string, most often a comma and
space in comment prose, can still open it. Both belong in the tooling,
which knows token context.
@holodorum
holodorum requested a review from dmarcotte October 1, 2026 15:42
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.

1 participant