Skip to content

showRange field regression: functionality lost during InlineCompletionsSource refactoring #279266

@yanmofeixi

Description

@yanmofeixi

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

  1. Create an extension using the inlineCompletionsAdditions proposed API
  2. Return an InlineCompletionItem with a showRange field set to a specific range
  3. Move the cursor outside of the showRange
  4. Expected: The inline completion should not be shown
  5. Actual: The inline completion is always shown regardless of cursor position

Root Cause Analysis

Working implementation (Jan 9, 2025 - commit a016c0b):

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:

  1. Store showRange in InlineSuggestData or InlineCompletionItem
  2. Check cursor position against this range before showing inline completions
  3. Only display when showRange.containsPosition(cursorPosition) or showRange is undefined

Related Commits

VS Code Version

Testing on current main branch (commit 0a2707c)

cc @hediet

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions