Skip to content

Commit d05ca61

Browse files
committed
get it to work
1 parent f34f7de commit d05ca61

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import { createStyleSheet2 } from 'vs/base/browser/dom';
77
import { alert } from 'vs/base/browser/ui/aria/aria';
8-
import { Event } from 'vs/base/common/event';
98
import { Disposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
109
import { IObservable, ITransaction, autorun, autorunHandleChanges, constObservable, derived, disposableObservableValue, observableFromEvent, observableSignal, observableValue, transaction } from 'vs/base/common/observable';
1110
import { CoreEditingCommands } from 'vs/editor/browser/coreCommands';
@@ -34,7 +33,6 @@ import { mapObservableArrayCached } from 'vs/base/common/observableInternal/util
3433
import { ISettableObservable, observableValueOpts } from 'vs/base/common/observableInternal/base';
3534
import { itemsEquals, itemEquals } from 'vs/base/common/equals';
3635
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
37-
import { ISpeechService } from 'vs/workbench/contrib/speech/common/speechService';
3836

3937
export class InlineCompletionsController extends Disposable {
4038
static ID = 'editor.contrib.inlineCompletionsController';
@@ -60,11 +58,10 @@ export class InlineCompletionsController extends Disposable {
6058
));
6159
private readonly _enabled = observableFromEvent(this.editor.onDidChangeConfiguration, () => this.editor.getOption(EditorOption.inlineSuggest).enabled);
6260
private readonly _isScreenReaderEnabled = observableFromEvent(this._accessibilityService.onDidChangeScreenReaderOptimized, () => this._accessibilityService.isScreenReaderOptimized());
63-
private readonly _onDidChangeSpeechToTextSession = Event.any(this._speechService.onDidStartSpeechToTextSession, this._speechService.onDidEndSpeechToTextSession);
64-
private readonly _voiceChatInProgress = observableFromEvent(this._onDidChangeSpeechToTextSession, () => this._speechService.hasActiveSpeechToTextSession);
61+
private readonly _editorDictationInProgress = observableFromEvent(this._contextKeyService.onDidChangeContext, () => this._contextKeyService.getContext(this.editor.getDomNode()).getValue('editorDictation.inProgress') === true);
6562

6663
private get _isEnabled(): boolean {
67-
return this._enabled.get() && (!this._isScreenReaderEnabled.get() || !this._voiceChatInProgress.get());
64+
return this._enabled.get() && (!this._isScreenReaderEnabled.get() || !this._editorDictationInProgress.get());
6865
}
6966

7067
private readonly _fontFamily = observableFromEvent(this.editor.onDidChangeConfiguration, () => this.editor.getOption(EditorOption.inlineSuggest).fontFamily);
@@ -107,7 +104,6 @@ export class InlineCompletionsController extends Disposable {
107104
@IAccessibilitySignalService private readonly _accessibilitySignalService: IAccessibilitySignalService,
108105
@IKeybindingService private readonly _keybindingService: IKeybindingService,
109106
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
110-
@ISpeechService private readonly _speechService: ISpeechService,
111107
) {
112108
super();
113109

@@ -134,7 +130,7 @@ export class InlineCompletionsController extends Disposable {
134130
observableFromEvent(editor.onDidChangeConfiguration, () => editor.getOption(EditorOption.inlineSuggest).mode),
135131
this._enabled,
136132
this._isScreenReaderEnabled,
137-
this._voiceChatInProgress
133+
this._editorDictationInProgress
138134
);
139135
this.model.set(model, tx);
140136
}
@@ -163,10 +159,12 @@ export class InlineCompletionsController extends Disposable {
163159
this.updateObservables(tx, getReason(e))
164160
)));
165161

166-
this._register(this._onDidChangeSpeechToTextSession(() => transaction(tx => {
167-
/** @description speechService.onDidChangeSpeechToTextSession */
168-
this.updateObservables(tx, VersionIdChangeReason.Other);
169-
this.model.get()?.stop(tx);
162+
this._register(this._contextKeyService.onDidChangeContext((e) => transaction(tx => {
163+
if (e.affectsSome(new Set('editorDictation.inProgress'))) {
164+
/** @description speechService.onDidChangeSpeechToTextSession */
165+
this.updateObservables(tx, VersionIdChangeReason.Other);
166+
this.model.get()?.stop(tx);
167+
}
170168
})));
171169

172170
this._register(editor.onDidChangeCursorPosition(e => transaction(tx => {
@@ -180,7 +178,6 @@ export class InlineCompletionsController extends Disposable {
180178
this._register(editor.onDidType(() => transaction(tx => {
181179
/** @description InlineCompletionsController.onDidType */
182180
this.updateObservables(tx, VersionIdChangeReason.Other);
183-
console.log('enabled', this._isEnabled);
184181
if (this._isEnabled) {
185182
this.model.get()?.trigger(tx);
186183
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class InlineCompletionsModel extends Disposable {
6161
private readonly _inlineSuggestMode: IObservable<'prefix' | 'subword' | 'subwordSmart'>,
6262
private readonly _enabled: IObservable<boolean>,
6363
private readonly _isScreenReaderEnabled: IObservable<boolean>,
64-
private readonly _voiceChatInProgress: IObservable<boolean>,
64+
private readonly _editorDictationInProgress: IObservable<boolean>,
6565
@IInstantiationService private readonly _instantiationService: IInstantiationService,
6666
@ICommandService private readonly _commandService: ICommandService,
6767
@ILanguageConfigurationService private readonly _languageConfigurationService: ILanguageConfigurationService,
@@ -109,7 +109,7 @@ export class InlineCompletionsModel extends Disposable {
109109
},
110110
}, (reader, changeSummary) => {
111111
this._forceUpdateExplicitlySignal.read(reader);
112-
const shouldUpdate = (this._enabled.read(reader) && (!this._isScreenReaderEnabled.read(reader) || !this._voiceChatInProgress.read(reader)) && this.selectedSuggestItem.read(reader)) || this._isActive.read(reader);
112+
const shouldUpdate = (this._enabled.read(reader) && (!this._isScreenReaderEnabled.read(reader) || !this._editorDictationInProgress.read(reader)) && this.selectedSuggestItem.read(reader)) || this._isActive.read(reader);
113113
if (!shouldUpdate) {
114114
this._source.cancelUpdate();
115115
return undefined;

0 commit comments

Comments
 (0)