(Note: this bug report was generated when I tried to get Claude Code to help me set up autocompletion, but I am a real person :) )
Describe the bug
Auto-triggered completions (via the . trigger character) always fail with -32600: invalid request from the LSP server. Completions only succeed when explicitly invoked with Ctrl+Space after a pause in typing.
This means member access completions (e.g., math.) never appear automatically in VSCode despite . being registered as a trigger character in the server's completionProvider capabilities.
To Reproduce
Open a .mojo file in VSCode with the Mojo extension installed
Add import math at the top
Inside a function, type math.
Observe: no completion popup appears
For comparison, place the cursor after math. and press Ctrl+Space — completions appear correctly.
Expected behavior
Typing . should trigger the completion popup automatically, as . is registered in the server's completionProvider.triggerCharacters.
LSP Trace Evidence
With mojo.trace.server: verbose enabled, the auto-triggered completion requests consistently fail:
I[10:57:50.352] --> textDocument/didChange (version=6)
I[10:57:50.352] --> textDocument/completion(18)
I[10:57:50.352] --> reply:textDocument/completion(18): -32600: invalid request
The explicit Ctrl+Space invocation (after a pause, no concurrent didChange) succeeds:
I[10:58:53.922] --> textDocument/completion(77)
I[10:58:54.800] --> reply:textDocument/completion(77)
{"id":77,"jsonrpc":"2.0","result":{"isIncomplete":false,"items":[...]}}
The root cause appears to be a race condition: the LSP rejects textDocument/completion requests that arrive concurrently with textDocument/didChange notifications. The auto-trigger fires at the same instant as the document change, causing the rejection. Ctrl+Space works because the user pauses before pressing it, allowing the document change to finish processing.
Environment
Mojo version: 0.26.2 (via pixi)
OS: Linux (Ubuntu)
VSCode extension: modular-mojotools.vscode-mojo 26.2.0
(Note: this bug report was generated when I tried to get Claude Code to help me set up autocompletion, but I am a real person :) )
Describe the bug
Auto-triggered completions (via the
.trigger character) always fail with-32600: invalid requestfrom the LSP server. Completions only succeed when explicitly invoked withCtrl+Spaceafter a pause in typing.This means member access completions (e.g.,
math.) never appear automatically in VSCode despite.being registered as a trigger character in the server'scompletionProvidercapabilities.To Reproduce
Open a .mojo file in VSCode with the Mojo extension installed
Add
import mathat the topInside a function, type
math.Observe: no completion popup appears
For comparison, place the cursor after
math.and pressCtrl+Space— completions appear correctly.Expected behavior
Typing
.should trigger the completion popup automatically, as.is registered in the server'scompletionProvider.triggerCharacters.LSP Trace Evidence
With mojo.trace.server: verbose enabled, the auto-triggered completion requests consistently fail:
The root cause appears to be a race condition: the LSP rejects
textDocument/completionrequests that arrive concurrently withtextDocument/didChangenotifications. The auto-trigger fires at the same instant as the document change, causing the rejection.Ctrl+Spaceworks because the user pauses before pressing it, allowing the document change to finish processing.Environment
Mojo version: 0.26.2 (via pixi)
OS: Linux (Ubuntu)
VSCode extension: modular-mojotools.vscode-mojo 26.2.0