Don't show word based suggestions when completion provider available#284094
Don't show word based suggestions when completion provider available#284094
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds a new configuration option 'offWithInlineSuggestions' to the word-based suggestions setting. This option is designed to disable word-based completions when inline completion providers (like GitHub Copilot) are available for the current file. The change includes both the configuration schema definition and the implementation logic in the completion provider.
Key changes:
- Adds 'offWithInlineSuggestions' enum value to the wordBasedSuggestions configuration
- Passes ILanguageFeaturesService to WordBasedCompletionItemProvider to check for inline completion provider availability
- Implements logic to skip word-based suggestions when the new option is set and inline completions are available
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/vs/editor/common/config/editorConfigurationSchema.ts | Adds new 'offWithInlineSuggestions' enum value with description and experiment flag |
| src/vs/editor/browser/services/editorWorkerService.ts | Adds ILanguageFeaturesService parameter and implements check to disable word-based completions when inline completion providers are available |
| nls.localize('wordBasedSuggestions.off', 'Turn off Word Based Suggestions.'), | ||
| nls.localize('wordBasedSuggestions.offWithInlineSuggestions', 'Turn off Word Based Suggestions when Inline Suggestions are present.'), |
There was a problem hiding this comment.
The enumDescriptions array order doesn't match the enum values order. The description for 'offWithInlineSuggestions' is placed second in the array, but 'offWithInlineSuggestions' is the last (5th) value in the enum. The descriptions should appear in the same order as their corresponding enum values: 'off', 'currentDocument', 'matchingDocuments', 'allDocuments', 'offWithInlineSuggestions'.
See below for a potential fix:
nls.localize('wordBasedSuggestions.currentDocument', 'Only suggest words from the active document.'),
nls.localize('wordBasedSuggestions.matchingDocuments', 'Suggest words from all open documents of the same language.'),
nls.localize('wordBasedSuggestions.allDocuments', 'Suggest words from all open documents.'),
nls.localize('wordBasedSuggestions.offWithInlineSuggestions', 'Turn off Word Based Suggestions when Inline Suggestions are present.'),
| enum: ['off', 'currentDocument', 'matchingDocuments', 'allDocuments', 'offWithInlineSuggestions'], | ||
| default: 'matchingDocuments', | ||
| enumDescriptions: [ | ||
| nls.localize('wordBasedSuggestions.off', 'Turn off Word Based Suggestions.'), | ||
| nls.localize('wordBasedSuggestions.offWithInlineSuggestions', 'Turn off Word Based Suggestions when Inline Suggestions are present.'), |
There was a problem hiding this comment.
The enum value 'offWithInlineSuggestions' is ambiguous. It's unclear whether this means "off when inline suggestions are present" or "off, but with inline suggestions enabled". Consider a more explicit name like 'offWhenInlineCompletions' or 'offWithInlineCompletions' to better convey that word-based suggestions are disabled when inline completion providers are available.
| enum: ['off', 'currentDocument', 'matchingDocuments', 'allDocuments', 'offWithInlineSuggestions'], | |
| default: 'matchingDocuments', | |
| enumDescriptions: [ | |
| nls.localize('wordBasedSuggestions.off', 'Turn off Word Based Suggestions.'), | |
| nls.localize('wordBasedSuggestions.offWithInlineSuggestions', 'Turn off Word Based Suggestions when Inline Suggestions are present.'), | |
| enum: ['off', 'offWithInlineCompletions', 'currentDocument', 'matchingDocuments', 'allDocuments'], | |
| default: 'matchingDocuments', | |
| enumDescriptions: [ | |
| nls.localize('wordBasedSuggestions.off', 'Turn off Word Based Suggestions.'), | |
| nls.localize('wordBasedSuggestions.offWithInlineCompletions', 'Turn off Word Based Suggestions when Inline Completions are present.'), |
| return undefined; | ||
| } | ||
|
|
||
| if (config.wordBasedSuggestions === 'offWithInlineSuggestions' && this.languageFeaturesService.inlineCompletionsProvider.has(model)) { |
There was a problem hiding this comment.
The public API type definition in standalone/browser/standaloneCodeEditor.ts (line 128) also defines wordBasedSuggestions but does not include the new 'offWithInlineSuggestions' option. Consider whether this new option should be exposed in the standalone API as well for consistency.
| if (config.wordBasedSuggestions === 'offWithInlineSuggestions' && this.languageFeaturesService.inlineCompletionsProvider.has(model)) { | ||
| return undefined; | ||
| } |
There was a problem hiding this comment.
When config.wordBasedSuggestions is 'offWithInlineSuggestions' but no inline completion provider is registered for the model, the function continues and falls into the else branch at line 293. This means 'offWithInlineSuggestions' will be treated like 'matchingDocuments' (line 302 check will fail, so it will match documents of the same language). This behavior is likely unintended. Consider what the expected behavior should be when 'offWithInlineSuggestions' is set but no inline completions provider is available - should it behave like 'matchingDocuments' or should there be an explicit fallback behavior?
Copilot Generated Description:Update the word-based suggestions configuration to include an option that disables suggestions when inline completions are available. Adjust the completion provider registration to accommodate this new behavior.closes #284076