Skip to content

Commit f34f7de

Browse files
committed
use speech service
1 parent 32e015a commit f34f7de

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
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';
89
import { Disposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
910
import { IObservable, ITransaction, autorun, autorunHandleChanges, constObservable, derived, disposableObservableValue, observableFromEvent, observableSignal, observableValue, transaction } from 'vs/base/common/observable';
1011
import { CoreEditingCommands } from 'vs/editor/browser/coreCommands';
@@ -33,6 +34,7 @@ import { mapObservableArrayCached } from 'vs/base/common/observableInternal/util
3334
import { ISettableObservable, observableValueOpts } from 'vs/base/common/observableInternal/base';
3435
import { itemsEquals, itemEquals } from 'vs/base/common/equals';
3536
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
37+
import { ISpeechService } from 'vs/workbench/contrib/speech/common/speechService';
3638

3739
export class InlineCompletionsController extends Disposable {
3840
static ID = 'editor.contrib.inlineCompletionsController';
@@ -58,9 +60,12 @@ export class InlineCompletionsController extends Disposable {
5860
));
5961
private readonly _enabled = observableFromEvent(this.editor.onDidChangeConfiguration, () => this.editor.getOption(EditorOption.inlineSuggest).enabled);
6062
private readonly _isScreenReaderEnabled = observableFromEvent(this._accessibilityService.onDidChangeScreenReaderOptimized, () => this._accessibilityService.isScreenReaderOptimized());
61-
private readonly _voiceChatInProgress = observableFromEvent(this._contextKeyService.onDidChangeContext, () => this._contextKeyService.getContext(this.editor.getDomNode()).getValue('voiceChatInProgress') === true);
63+
private readonly _onDidChangeSpeechToTextSession = Event.any(this._speechService.onDidStartSpeechToTextSession, this._speechService.onDidEndSpeechToTextSession);
64+
private readonly _voiceChatInProgress = observableFromEvent(this._onDidChangeSpeechToTextSession, () => this._speechService.hasActiveSpeechToTextSession);
6265

63-
private readonly _isEnabled = this._enabled.get() && (!this._isScreenReaderEnabled.get() || !this._voiceChatInProgress.get());
66+
private get _isEnabled(): boolean {
67+
return this._enabled.get() && (!this._isScreenReaderEnabled.get() || !this._voiceChatInProgress.get());
68+
}
6469

6570
private readonly _fontFamily = observableFromEvent(this.editor.onDidChangeConfiguration, () => this.editor.getOption(EditorOption.inlineSuggest).fontFamily);
6671

@@ -102,6 +107,7 @@ export class InlineCompletionsController extends Disposable {
102107
@IAccessibilitySignalService private readonly _accessibilitySignalService: IAccessibilitySignalService,
103108
@IKeybindingService private readonly _keybindingService: IKeybindingService,
104109
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
110+
@ISpeechService private readonly _speechService: ISpeechService,
105111
) {
106112
super();
107113

@@ -157,6 +163,12 @@ export class InlineCompletionsController extends Disposable {
157163
this.updateObservables(tx, getReason(e))
158164
)));
159165

166+
this._register(this._onDidChangeSpeechToTextSession(() => transaction(tx => {
167+
/** @description speechService.onDidChangeSpeechToTextSession */
168+
this.updateObservables(tx, VersionIdChangeReason.Other);
169+
this.model.get()?.stop(tx);
170+
})));
171+
160172
this._register(editor.onDidChangeCursorPosition(e => transaction(tx => {
161173
/** @description InlineCompletionsController.onDidChangeCursorPosition */
162174
this.updateObservables(tx, VersionIdChangeReason.Other);

0 commit comments

Comments
 (0)