-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Improve Autocomplete Text Insertion when prefix/suffix matches existing text in the Document #602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
372d323 to
f1e7c8f
Compare
be87c60 to
614b2c3
Compare
- eliminate static instance to simplify class design - adjust animation manager initialization to use new operator
- integrate processTextInsertion to handle overlapping text - enhance createInlineCompletionItem to use insertRange ✅ test(autocomplete): add tests for CompletionTextProcessor - add unit tests for processTextInsertion function - include MockTextEditor and MockTextDocument for testing - test various completion and overlap scenarios
…er for better request management Use AbortController instead of requestId tracking - modify error handling to exclude expected AbortErrors - ensure smoother user experience by avoiding unnecessary error logs
- Introduce `AutocompleteStatusBar` class to manage status bar display. - Display current state with cost information and token validation. ♻️ refactor(autocomplete): centralize state management - Consolidate autocomplete state into a single `AutocompleteState` object. - Simplify state updates and improve readability. ✅ test(autocomplete): add tests for AutocompleteStatusBar - Implement unit tests for `AutocompleteStatusBar` behavior. - Verify correct display text and tooltip for different states. ✨ feat(utils): add cost formatting utility - Create `formatCost` utility for consistent cost display. - Handle small amount formatting with precision. ✅ test(utils): add tests for cost formatting utility - Test `formatCost` function for various input scenarios. - Ensure correct formatting for zero, small, and large amounts.
- replace LRUCache with AutocompleteCache for better modularity - remove generateCacheKey function from AutocompleteProvider - implement cache key generation within AutocompleteCache - streamline cache operations with new findMatchingCompletion and addCompletion methods ✨ feat(cache): introduce AutocompleteCache class - create AutocompleteCache class to handle completion caching - include methods for adding and retrieving completions - ensure cache size and TTL are configurable - provide cache clearing functionality
…eContext Often we need to pass all three at the same time, so let's just put the document and position into the context. Also: - remove unnecessary parameters from function calls - streamline cache operations - remove text insertion options for prefix and suffix trimming - default trimming behavior to always active
- introduce `Autocompletion` type to encapsulate completion data - update cache to store structured `Autocompletion` objects - modify completion generation to return structured results ♻️ refactor(autocomplete): improve completion processing logic - adjust completion processing to use structured data - streamline cache interactions with new `Autocompletion` type - revise log outputs to reflect structured completion data 🐛 fix(autocomplete): correct cache entry duplication detection - ensure completions are checked against structured data for uniqueness - prevent duplicate cache entries by comparing full structured objects
- introduce lastCompletionTime to track completion duration - display completion time in status bar if available ✅ test(autocomplete): ensure completion time is tested - add tests for status bar display with completion time - verify correct formatting in tooltip and text display ♻️ refactor(templating): simplify AutocompleteTemplate formatting - remove redundant example queries from template - streamline user prompt generation logic
- extract duplicated API handler creation logic into a helper function - improve maintainability and readability by centralizing logic ✅ test(autocomplete): add tests for API handler creation logic - verify the refactored API handler creation logic in dedicated test file - ensure correct behavior for various token configurations ✅ test(autocomplete): add tests for token validation logic - verify token validation is correctly derived from API handler state - ensure accurate token status updates across different scenarios 💄 style(autocomplete): enhance status bar display - add completion time to status bar text for improved user feedback
614b2c3 to
bc03f2b
Compare
- replace timer-based animation with abortable delay for better control - introduce runAnimation method to handle animation lifecycle - use AbortController to manage animation cancellation ✅ test(autocomplete): add tests for abortableDelay utility - ensure delay resolves after specified time - verify delay rejects when aborted before completion - test immediate rejection if signal is already aborted ✨ feat(utils): add abortableDelay utility function - create a promise-based delay that can be aborted - support cancellation through AbortSignal for flexible use
bc03f2b to
366c3f3
Compare
|
Closing this PR as most of tit was included in #1130 |
This improves the behavior of autocomplete in cases where the text in the document may already contain a prefix or suffix from the completion.
Now, with this change, we add more complex prefix and suffix checking, and we only insert the completion preview with matching text removed, greatly improving the issue where we duplicate closing braces.