Improve completion triggering + add parameter hints (signature help)#1234
Merged
Conversation
Completion previously only auto-triggered after "." and relied on Monaco
defaults that weren't configured. Make it behave more like Xcode:
- Editor options: quickSuggestions on (code), quickSuggestionsDelay 0,
suggestOnTriggerCharacters, tabCompletion — so suggestions pop while typing.
- More completion trigger characters: "(", ":", "<", " ", "," in addition to ".".
- Explicit Ctrl+Space action bound to editor.action.triggerSuggest (Cmd+Space
is taken by Spotlight on macOS, so bind Control).
Add Signature Help (parameter hints):
- Register a Monaco signatureHelpProvider (trigger on "(" and ",").
- New requestSignatureHelp() sends the `signatureHelp` method to the backend
and the response is mapped to Monaco's SignatureHelp shape.
Also fix a pre-existing bug: the `completion` case in the response handler was
missing a `break` and fell through into `diagnostics`, clearing the diagnostic
markers on every completion.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the Monaco-based Swift editor to make completion trigger more predictably (more like Xcode) and adds signature help (parameter hints) via a new backend signatureHelp request.
Changes:
- Enable Monaco suggestion options (quick suggestions, no delay, trigger characters, Tab completion).
- Expand completion trigger characters and add an explicit Ctrl+Space action to manually trigger suggestions.
- Add a signature help provider wired through the web language server client and response handler (including fixing a completion fall-through bug via a missing
break).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Public/js/main_view.js | Enables Monaco suggestion behavior (quick suggestions, delay, trigger characters, Tab completion). |
| Public/js/language_server.js | Adds a requestSignatureHelp request method to the WS language-server protocol client. |
| Public/js/editor.js | Expands completion triggers, registers a signature help provider, and binds Ctrl+Space to trigger suggest. |
| Public/js/app.js | Handles signatureHelp responses and wires editor signature help requests; adds missing break after completion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
118
to
+121
| } else { | ||
| promise.fulfill(); | ||
| } | ||
| break; |
Comment on lines
+148
to
+151
| } else { | ||
| promise.fulfill(); | ||
| } | ||
| break; |
Comment on lines
38
to
41
| monaco.languages.registerCompletionItemProvider("swift", { | ||
| triggerCharacters: ["."], | ||
| triggerCharacters: [".", "(", ":", "<", " ", ","], | ||
| provideCompletionItems: (model, position) => { | ||
| return this.oncompletion(position); |
`promises` is keyed by an ever-incrementing sequence and nothing removed entries, so it grew unbounded — now worse since completion fires on every keystroke (quick suggestions + more trigger characters) and signature help fires inside calls. Delete the entry right after retrieving it in onresponse, covering hover/completion/signatureHelp at once (no-op for diagnostics/format). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A literal space triggered the completion provider (and a backend request) on every whitespace keystroke — very frequent and returning a large, unfiltered list. quickSuggestions already shows suggestions once the next identifier is typed, so the space trigger only added wasteful traffic. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes code completion behave more like Xcode and adds parameter hints.
Completion triggering
Previously completion only auto-triggered after
., and the editor never configured Monaco's suggestion options, so it felt unpredictable.main_view.js):quickSuggestionson for code,quickSuggestionsDelay: 0,suggestOnTriggerCharacters,tabCompletion: "on"— suggestions now pop up while typing.editor.js):.(:<space,.editor.action.triggerSuggest(Cmd+Space is Spotlight on macOS, so Control is used) — Xcode-style manual trigger.Parameter hints (signature help)
registerSignatureHelpProvider(triggers on(and,).requestSignatureHelp()sends a newsignatureHelpmethod; the response maps to Monaco'sSignatureHelp(signatures / parameters / activeParameter), so the active argument is highlighted as you type.Bug fix
The
completioncase in the response handler was missing abreakand fell through intodiagnostics, clearing the editor's diagnostic markers on every completion request. Added thebreak.Notes
signatureHelpmethod (Add signatureHelp (parameter hints) to the LSP WebSocket API swiftfiddle-lsp#357).🤖 Generated with Claude Code