-
Notifications
You must be signed in to change notification settings - Fork 36.4k
Description
Does this issue occur when all extensions are disabled?: No
- VS Code Version:
- OS Version:
Description
The showRange field in InlineCompletionItem (part of the inlineCompletionsAdditions proposed API) is currently not working. While the field is
still defined in the API and accepted from extensions, the implementation that checks cursor position against this range was completely removed during a refactoring.
Steps to Reproduce
- Create an extension using the inlineCompletionsAdditions proposed API
- Return an InlineCompletionItem with a showRange field set to a specific range
- Move the cursor outside of the showRange
- Expected: The inline completion should not be shown
- Actual: The inline completion is always shown regardless of cursor position
Root Cause Analysis
Working implementation (Jan 9, 2025 - commit a016c0b):
- PR Support show range for inline edits #237532 added support for showRange
- InlineCompletionItem had a cursorShowRange field
- inlineCompletionsModel.ts checked: cursorShowRange?.containsPosition(cursorPos) ?? true
Regression (Apr 7, 2025 - commit b0abf06):
- Major refactoring of InlineCompletionsSource
- The cursorShowRange field was removed from InlineCompletionItem
- All cursor position checking logic was deleted
- However, the API definition remains in vscode.proposed.inlineCompletionsAdditions.d.ts
Evidence
API layer still accepts the field:
// src/vs/workbench/api/common/extHostLanguageFeatures.ts:1431
showRange: (this._isAdditionsProposedApiEnabled && item.showRange)
? typeConvert.Range.from(item.showRange) : undefined
Internal implementation doesn't use it:
- InlineSuggestData constructor doesn't receive showRange parameter
- InlineCompletionItem.create() doesn't process showRange from inlineCompletion
- No cursor position checks against showRange exist in current codebase
Affected Files
- src/vs/editor/contrib/inlineCompletions/browser/model/provideInlineCompletions.ts
- src/vs/editor/contrib/inlineCompletions/browser/model/inlineSuggestionItem.ts
- src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.ts
Expected Fix
Restore the showRange functionality:
- Store showRange in InlineSuggestData or InlineCompletionItem
- Check cursor position against this range before showing inline completions
- Only display when showRange.containsPosition(cursorPosition) or showRange is undefined
Related Commits
- ✅ Added: a016c0b - Support show range for inline edits (Support show range for inline edits #237532)
- ❌ Removed: b0abf06 - Refactors InlineCompletionsSource
VS Code Version
Testing on current main branch (commit 0a2707c)
cc @hediet