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' ;
9
8
import { Disposable , DisposableStore , toDisposable } from 'vs/base/common/lifecycle' ;
10
9
import { IObservable , ITransaction , autorun , autorunHandleChanges , constObservable , derived , disposableObservableValue , observableFromEvent , observableSignal , observableValue , transaction } from 'vs/base/common/observable' ;
11
10
import { CoreEditingCommands } from 'vs/editor/browser/coreCommands' ;
@@ -34,7 +33,6 @@ import { mapObservableArrayCached } from 'vs/base/common/observableInternal/util
34
33
import { ISettableObservable , observableValueOpts } from 'vs/base/common/observableInternal/base' ;
35
34
import { itemsEquals , itemEquals } from 'vs/base/common/equals' ;
36
35
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility' ;
37
- import { ISpeechService } from 'vs/workbench/contrib/speech/common/speechService' ;
38
36
39
37
export class InlineCompletionsController extends Disposable {
40
38
static ID = 'editor.contrib.inlineCompletionsController' ;
@@ -60,11 +58,10 @@ export class InlineCompletionsController extends Disposable {
60
58
) ) ;
61
59
private readonly _enabled = observableFromEvent ( this . editor . onDidChangeConfiguration , ( ) => this . editor . getOption ( EditorOption . inlineSuggest ) . enabled ) ;
62
60
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 ) ;
65
62
66
63
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 ( ) ) ;
68
65
}
69
66
70
67
private readonly _fontFamily = observableFromEvent ( this . editor . onDidChangeConfiguration , ( ) => this . editor . getOption ( EditorOption . inlineSuggest ) . fontFamily ) ;
@@ -107,7 +104,6 @@ export class InlineCompletionsController extends Disposable {
107
104
@IAccessibilitySignalService private readonly _accessibilitySignalService : IAccessibilitySignalService ,
108
105
@IKeybindingService private readonly _keybindingService : IKeybindingService ,
109
106
@IAccessibilityService private readonly _accessibilityService : IAccessibilityService ,
110
- @ISpeechService private readonly _speechService : ISpeechService ,
111
107
) {
112
108
super ( ) ;
113
109
@@ -134,7 +130,7 @@ export class InlineCompletionsController extends Disposable {
134
130
observableFromEvent ( editor . onDidChangeConfiguration , ( ) => editor . getOption ( EditorOption . inlineSuggest ) . mode ) ,
135
131
this . _enabled ,
136
132
this . _isScreenReaderEnabled ,
137
- this . _voiceChatInProgress
133
+ this . _editorDictationInProgress
138
134
) ;
139
135
this . model . set ( model , tx ) ;
140
136
}
@@ -163,10 +159,12 @@ export class InlineCompletionsController extends Disposable {
163
159
this . updateObservables ( tx , getReason ( e ) )
164
160
) ) ) ;
165
161
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
+ }
170
168
} ) ) ) ;
171
169
172
170
this . _register ( editor . onDidChangeCursorPosition ( e => transaction ( tx => {
@@ -180,7 +178,6 @@ export class InlineCompletionsController extends Disposable {
180
178
this . _register ( editor . onDidType ( ( ) => transaction ( tx => {
181
179
/** @description InlineCompletionsController.onDidType */
182
180
this . updateObservables ( tx , VersionIdChangeReason . Other ) ;
183
- console . log ( 'enabled' , this . _isEnabled ) ;
184
181
if ( this . _isEnabled ) {
185
182
this . model . get ( ) ?. trigger ( tx ) ;
186
183
}
0 commit comments