Before: Used async/await which blocked other completion providers
After: Returns a promise immediately, allowing other providers to show results first
Added: 2-second cache for completion items at the same position
Benefit: Repeated triggers (typing multiple dots) use cached results
Code Actions: 1 second timeout
Navigation Commands: 500ms timeout per provider
Benefit: Won't hang if language server is slow
Before: Navigation commands fetched sequentially (slow)
After: All navigation providers fetched in parallel
Benefit: 4x faster for navigation commands
Added: Checks token.isCancellationRequested throughout
Benefit: Stops processing if user types more or closes completion
Added: Filters out lazy actions immediately
Benefit: Less processing, cleaner results
- < 1ms - Returns cached results immediately
- Code Actions: Up to 1000ms (with timeout)
- Navigation: Up to 500ms (with timeout)
- Total: ~1.5 seconds max
Dart language server can be slower, especially for:
- Large projects
- First completion after opening file
- Complex widget trees
The timeouts ensure we never block longer than 1.5 seconds total.
- Type
.→ Other autocomplete appears immediately - Wait ~1 second → Our commands appear below
- Type more → Cancels our fetch, no wasted work
- Other completion providers aren't blocked
- Normal autocomplete shows first
- Our commands appear after (sorted with
~prefix) - Users can start typing immediately
Could add settings for:
commandCompletion.timeout- Adjust timeout (default: 1000ms)commandCompletion.cacheTimeout- Adjust cache TTL (default: 2000ms)commandCompletion.enableNavigation- Toggle navigation commandscommandCompletion.enableCodeActions- Toggle code actions
Check Debug Console for:
Command completion triggered at position: ...
Found X dot(s)
Using cached completion items ← Cache hit!
Found X code actions
Code action fetch timed out ← Timeout triggered
- Ensure Dart/Flutter extension is up to date
- Check if project analysis is complete
- Try smaller timeout: Reduce from 1000ms to 500ms
- Check if other extensions are slow too
- Disable other completion extensions temporarily
- Check CPU usage during completion
- Map-based cache with position as key
- 2-second TTL (Time To Live)
- Max 50 entries (LRU-style cleanup)
- Cleared on file changes (implicit via position change)
Promise.race()between actual fetch and timeout- Returns empty array on timeout
- Doesn't throw errors, just returns partial results
Promise.all()for navigation commands- Each wrapped in
Promise.race()with timeout - All 4 providers fetch simultaneously
Type . → Wait 3-5 seconds → All completions appear together
Type . → Normal autocomplete appears immediately
→ Our commands appear 1-1.5 seconds later (below)
This is the correct behavior - we don't block other providers!