feat(completion): trigger import completion on space - #460
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds space as an LSP completion trigger, propagates trigger context through the server, filters VS Code space-triggered requests by import context, and expands unit, integration, and end-to-end completion coverage. ChangesSpace-triggered completion
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant VSCode
participant LSPClient
participant FeatureRouter
participant CompletionContext
VSCode->>LSPClient: completion request with trigger character
LSPClient->>FeatureRouter: completion(position, trigger_character)
FeatureRouter->>CompletionContext: detect preamble context
FeatureRouter-->>LSPClient: filtered or normal completion result
LSPClient-->>VSCode: completion response
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 299e28f7ad
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Register space as a completion trigger character so that typing `import ` immediately shows module name suggestions without needing to type the first character of the module name. - Server: add space to trigger_characters in CompletionOptions. - Extension: middleware gate filters space triggers, only forwarding to the server when the line is `import ` or `export import `. - Tests: cover dotted modules, partition prefixes, and empty-prefix cases for detect_completion_context and complete_module_import. - Add FIXME/TODO annotations for known issues (self-import in results, textual detection false positives, incremental refresh).
Space is advertised as a completion trigger to every client, but the import-line filtering lived only in the VS Code middleware; nvim and zed would fire a full completion build on every space keystroke. Answer space-triggered requests outside import contexts with an empty list in FeatureRouter::completion so all clients are protected. Also assert the advertised trigger characters in test_capabilities, cover both sides of the gate with integration tests, exercise the middleware in the vscode e2e suite, and apply review nits (comment placement, test naming, mid-line cursor case).
299e28f to
59dc9c1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 59dc9c1993
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A space typed while the cursor is still in an include context (e.g. the trailing space in '#include <vector> ') previously reached the include branch and performed command resolution and directory enumeration before the gate. Hoist the context detection and check the gate first so a space trigger only ever serves import contexts.
Summary
importimmediately opens the module name suggestion list (same UX as#include <triggering header suggestions).importorexport import, avoiding the request round-trip entirely in the common case.Approach
Follows the same pattern as TypeScript/Haxe language extensions (vscode#67714): the server advertises space as a trigger character and the client does a cheap string check to avoid flooding the server — with the addition that the server independently enforces the same rule, so the UX guarantee does not depend on any particular editor integration.
Test plan
detect_completion_context(dotted module prefix, partition prefix, empty partition, leading whitespace,export import, multiline import, mid-line cursor truncation) andcomplete_module_import(dotted/partition prefix filtering, prefix-equals-full-name)." "intriggerCharacters; space trigger on an import line serves module completions; space trigger elsewhere returns an empty list.Summary by CodeRabbit
importandexport importcontexts.*.