mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-06 05:14:41 +01:00
get it to work
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
|
||||
import { createStyleSheet2 } from 'vs/base/browser/dom';
|
||||
import { alert } from 'vs/base/browser/ui/aria/aria';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { Disposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IObservable, ITransaction, autorun, autorunHandleChanges, constObservable, derived, disposableObservableValue, observableFromEvent, observableSignal, observableValue, transaction } from 'vs/base/common/observable';
|
||||
import { CoreEditingCommands } from 'vs/editor/browser/coreCommands';
|
||||
@@ -34,7 +33,6 @@ import { mapObservableArrayCached } from 'vs/base/common/observableInternal/util
|
||||
import { ISettableObservable, observableValueOpts } from 'vs/base/common/observableInternal/base';
|
||||
import { itemsEquals, itemEquals } from 'vs/base/common/equals';
|
||||
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { ISpeechService } from 'vs/workbench/contrib/speech/common/speechService';
|
||||
|
||||
export class InlineCompletionsController extends Disposable {
|
||||
static ID = 'editor.contrib.inlineCompletionsController';
|
||||
@@ -60,11 +58,10 @@ export class InlineCompletionsController extends Disposable {
|
||||
));
|
||||
private readonly _enabled = observableFromEvent(this.editor.onDidChangeConfiguration, () => this.editor.getOption(EditorOption.inlineSuggest).enabled);
|
||||
private readonly _isScreenReaderEnabled = observableFromEvent(this._accessibilityService.onDidChangeScreenReaderOptimized, () => this._accessibilityService.isScreenReaderOptimized());
|
||||
private readonly _onDidChangeSpeechToTextSession = Event.any(this._speechService.onDidStartSpeechToTextSession, this._speechService.onDidEndSpeechToTextSession);
|
||||
private readonly _voiceChatInProgress = observableFromEvent(this._onDidChangeSpeechToTextSession, () => this._speechService.hasActiveSpeechToTextSession);
|
||||
private readonly _editorDictationInProgress = observableFromEvent(this._contextKeyService.onDidChangeContext, () => this._contextKeyService.getContext(this.editor.getDomNode()).getValue('editorDictation.inProgress') === true);
|
||||
|
||||
private get _isEnabled(): boolean {
|
||||
return this._enabled.get() && (!this._isScreenReaderEnabled.get() || !this._voiceChatInProgress.get());
|
||||
return this._enabled.get() && (!this._isScreenReaderEnabled.get() || !this._editorDictationInProgress.get());
|
||||
}
|
||||
|
||||
private readonly _fontFamily = observableFromEvent(this.editor.onDidChangeConfiguration, () => this.editor.getOption(EditorOption.inlineSuggest).fontFamily);
|
||||
@@ -107,7 +104,6 @@ export class InlineCompletionsController extends Disposable {
|
||||
@IAccessibilitySignalService private readonly _accessibilitySignalService: IAccessibilitySignalService,
|
||||
@IKeybindingService private readonly _keybindingService: IKeybindingService,
|
||||
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
|
||||
@ISpeechService private readonly _speechService: ISpeechService,
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -134,7 +130,7 @@ export class InlineCompletionsController extends Disposable {
|
||||
observableFromEvent(editor.onDidChangeConfiguration, () => editor.getOption(EditorOption.inlineSuggest).mode),
|
||||
this._enabled,
|
||||
this._isScreenReaderEnabled,
|
||||
this._voiceChatInProgress
|
||||
this._editorDictationInProgress
|
||||
);
|
||||
this.model.set(model, tx);
|
||||
}
|
||||
@@ -163,10 +159,12 @@ export class InlineCompletionsController extends Disposable {
|
||||
this.updateObservables(tx, getReason(e))
|
||||
)));
|
||||
|
||||
this._register(this._onDidChangeSpeechToTextSession(() => transaction(tx => {
|
||||
/** @description speechService.onDidChangeSpeechToTextSession */
|
||||
this.updateObservables(tx, VersionIdChangeReason.Other);
|
||||
this.model.get()?.stop(tx);
|
||||
this._register(this._contextKeyService.onDidChangeContext((e) => transaction(tx => {
|
||||
if (e.affectsSome(new Set('editorDictation.inProgress'))) {
|
||||
/** @description speechService.onDidChangeSpeechToTextSession */
|
||||
this.updateObservables(tx, VersionIdChangeReason.Other);
|
||||
this.model.get()?.stop(tx);
|
||||
}
|
||||
})));
|
||||
|
||||
this._register(editor.onDidChangeCursorPosition(e => transaction(tx => {
|
||||
@@ -180,7 +178,6 @@ export class InlineCompletionsController extends Disposable {
|
||||
this._register(editor.onDidType(() => transaction(tx => {
|
||||
/** @description InlineCompletionsController.onDidType */
|
||||
this.updateObservables(tx, VersionIdChangeReason.Other);
|
||||
console.log('enabled', this._isEnabled);
|
||||
if (this._isEnabled) {
|
||||
this.model.get()?.trigger(tx);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ export class InlineCompletionsModel extends Disposable {
|
||||
private readonly _inlineSuggestMode: IObservable<'prefix' | 'subword' | 'subwordSmart'>,
|
||||
private readonly _enabled: IObservable<boolean>,
|
||||
private readonly _isScreenReaderEnabled: IObservable<boolean>,
|
||||
private readonly _voiceChatInProgress: IObservable<boolean>,
|
||||
private readonly _editorDictationInProgress: IObservable<boolean>,
|
||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||
@ICommandService private readonly _commandService: ICommandService,
|
||||
@ILanguageConfigurationService private readonly _languageConfigurationService: ILanguageConfigurationService,
|
||||
@@ -109,7 +109,7 @@ export class InlineCompletionsModel extends Disposable {
|
||||
},
|
||||
}, (reader, changeSummary) => {
|
||||
this._forceUpdateExplicitlySignal.read(reader);
|
||||
const shouldUpdate = (this._enabled.read(reader) && (!this._isScreenReaderEnabled.read(reader) || !this._voiceChatInProgress.read(reader)) && this.selectedSuggestItem.read(reader)) || this._isActive.read(reader);
|
||||
const shouldUpdate = (this._enabled.read(reader) && (!this._isScreenReaderEnabled.read(reader) || !this._editorDictationInProgress.read(reader)) && this.selectedSuggestItem.read(reader)) || this._isActive.read(reader);
|
||||
if (!shouldUpdate) {
|
||||
this._source.cancelUpdate();
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user