5
5
6
6
import { createStyleSheet2 } from 'vs/base/browser/dom' ;
7
7
import { alert } from 'vs/base/browser/ui/aria/aria' ;
8
+ import { Event } from 'vs/base/common/event' ;
8
9
import { Disposable , DisposableStore , toDisposable } from 'vs/base/common/lifecycle' ;
9
10
import { IObservable , ITransaction , autorun , autorunHandleChanges , constObservable , derived , disposableObservableValue , observableFromEvent , observableSignal , observableValue , transaction } from 'vs/base/common/observable' ;
10
11
import { CoreEditingCommands } from 'vs/editor/browser/coreCommands' ;
@@ -33,6 +34,7 @@ import { mapObservableArrayCached } from 'vs/base/common/observableInternal/util
33
34
import { ISettableObservable , observableValueOpts } from 'vs/base/common/observableInternal/base' ;
34
35
import { itemsEquals , itemEquals } from 'vs/base/common/equals' ;
35
36
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility' ;
37
+ import { ISpeechService } from 'vs/workbench/contrib/speech/common/speechService' ;
36
38
37
39
export class InlineCompletionsController extends Disposable {
38
40
static ID = 'editor.contrib.inlineCompletionsController' ;
@@ -58,9 +60,12 @@ export class InlineCompletionsController extends Disposable {
58
60
) ) ;
59
61
private readonly _enabled = observableFromEvent ( this . editor . onDidChangeConfiguration , ( ) => this . editor . getOption ( EditorOption . inlineSuggest ) . enabled ) ;
60
62
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 ) ;
62
65
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
+ }
64
69
65
70
private readonly _fontFamily = observableFromEvent ( this . editor . onDidChangeConfiguration , ( ) => this . editor . getOption ( EditorOption . inlineSuggest ) . fontFamily ) ;
66
71
@@ -102,6 +107,7 @@ export class InlineCompletionsController extends Disposable {
102
107
@IAccessibilitySignalService private readonly _accessibilitySignalService : IAccessibilitySignalService ,
103
108
@IKeybindingService private readonly _keybindingService : IKeybindingService ,
104
109
@IAccessibilityService private readonly _accessibilityService : IAccessibilityService ,
110
+ @ISpeechService private readonly _speechService : ISpeechService ,
105
111
) {
106
112
super ( ) ;
107
113
@@ -157,6 +163,12 @@ export class InlineCompletionsController extends Disposable {
157
163
this . updateObservables ( tx , getReason ( e ) )
158
164
) ) ) ;
159
165
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
+
160
172
this . _register ( editor . onDidChangeCursorPosition ( e => transaction ( tx => {
161
173
/** @description InlineCompletionsController.onDidChangeCursorPosition */
162
174
this . updateObservables ( tx , VersionIdChangeReason . Other ) ;
0 commit comments