Skip to content

Commit 75ddb39

Browse files
committed
1 parent e8e027a commit 75ddb39

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/vs/editor/contrib/inlineCompletions/browser/inlineCompletionsController.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
3232
import { mapObservableArrayCached } from 'vs/base/common/observableInternal/utils';
3333
import { ISettableObservable, observableValueOpts } from 'vs/base/common/observableInternal/base';
3434
import { itemsEquals, itemEquals } from 'vs/base/common/equals';
35+
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
3536

3637
export class InlineCompletionsController extends Disposable {
3738
static ID = 'editor.contrib.inlineCompletionsController';
@@ -56,6 +57,9 @@ export class InlineCompletionsController extends Disposable {
5657
}
5758
));
5859
private readonly _enabled = observableFromEvent(this.editor.onDidChangeConfiguration, () => this.editor.getOption(EditorOption.inlineSuggest).enabled);
60+
private readonly _enabledForScreenReader = observableFromEvent(this._accessibilityService.onDidChangeScreenReaderOptimized, () => !this._accessibilityService.isScreenReaderOptimized() || this._contextKeyService.getContextKeyValue('voiceChatInProgress') === false);
61+
private readonly _isEnabled = this._enabled.get() && this._enabledForScreenReader.get();
62+
5963
private readonly _fontFamily = observableFromEvent(this.editor.onDidChangeConfiguration, () => this.editor.getOption(EditorOption.inlineSuggest).fontFamily);
6064

6165
private readonly _ghostTexts = derived(this, (reader) => {
@@ -95,6 +99,7 @@ export class InlineCompletionsController extends Disposable {
9599
@ILanguageFeaturesService private readonly _languageFeaturesService: ILanguageFeaturesService,
96100
@IAccessibilitySignalService private readonly _accessibilitySignalService: IAccessibilitySignalService,
97101
@IKeybindingService private readonly _keybindingService: IKeybindingService,
102+
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
98103
) {
99104
super();
100105

@@ -120,6 +125,7 @@ export class InlineCompletionsController extends Disposable {
120125
observableFromEvent(editor.onDidChangeConfiguration, () => editor.getOption(EditorOption.suggest).previewMode),
121126
observableFromEvent(editor.onDidChangeConfiguration, () => editor.getOption(EditorOption.inlineSuggest).mode),
122127
this._enabled,
128+
this._enabledForScreenReader
123129
);
124130
this.model.set(model, tx);
125131
}
@@ -159,7 +165,7 @@ export class InlineCompletionsController extends Disposable {
159165
this._register(editor.onDidType(() => transaction(tx => {
160166
/** @description InlineCompletionsController.onDidType */
161167
this.updateObservables(tx, VersionIdChangeReason.Other);
162-
if (this._enabled.get()) {
168+
if (this._isEnabled) {
163169
this.model.get()?.trigger(tx);
164170
}
165171
})));
@@ -173,7 +179,7 @@ export class InlineCompletionsController extends Disposable {
173179
inlineSuggestCommitId,
174180
'acceptSelectedSuggestion',
175181
]);
176-
if (commands.has(e.commandId) && editor.hasTextFocus() && this._enabled.get()) {
182+
if (commands.has(e.commandId) && editor.hasTextFocus() && this._isEnabled) {
177183
transaction(tx => {
178184
/** @description onDidExecuteCommand */
179185
this.model.get()?.trigger(tx);

src/vs/editor/contrib/inlineCompletions/browser/inlineCompletionsModel.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class InlineCompletionsModel extends Disposable {
6060
private readonly _suggestPreviewMode: IObservable<'prefix' | 'subword' | 'subwordSmart'>,
6161
private readonly _inlineSuggestMode: IObservable<'prefix' | 'subword' | 'subwordSmart'>,
6262
private readonly _enabled: IObservable<boolean>,
63+
private readonly _enabledForScreenReader: IObservable<boolean>,
6364
@IInstantiationService private readonly _instantiationService: IInstantiationService,
6465
@ICommandService private readonly _commandService: ICommandService,
6566
@ILanguageConfigurationService private readonly _languageConfigurationService: ILanguageConfigurationService,
@@ -107,7 +108,7 @@ export class InlineCompletionsModel extends Disposable {
107108
},
108109
}, (reader, changeSummary) => {
109110
this._forceUpdateExplicitlySignal.read(reader);
110-
const shouldUpdate = (this._enabled.read(reader) && this.selectedSuggestItem.read(reader)) || this._isActive.read(reader);
111+
const shouldUpdate = (this._enabled.read(reader) && this._enabledForScreenReader.read(reader) && this.selectedSuggestItem.read(reader)) || this._isActive.read(reader);
111112
if (!shouldUpdate) {
112113
this._source.cancelUpdate();
113114
return undefined;

0 commit comments

Comments
 (0)