Skip to content

Commit 82d1ae4

Browse files
authored
Merge pull request microsoft#203268 from microsoft/merogge/inline-cue
factor in alert enabled for line feature cues
2 parents b9ee99d + 076bd0b commit 82d1ae4

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/vs/editor/standalone/browser/standaloneServices.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,10 @@ class StandaloneAudioService implements IAudioCueService {
10771077
return Event.None;
10781078
}
10791079

1080+
onAlertEnabledChanged(cue: AudioCue): Event<void> {
1081+
return Event.None;
1082+
}
1083+
10801084
async playSound(cue: Sound, allowManyInParallel?: boolean | undefined): Promise<void> {
10811085
}
10821086
playAudioCueLoop(cue: AudioCue): IDisposable {

src/vs/platform/audioCues/browser/audioCueService.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface IAudioCueService {
2222
isCueEnabled(cue: AudioCue): boolean;
2323
isAlertEnabled(cue: AudioCue): boolean;
2424
onEnabledChanged(cue: AudioCue): Event<void>;
25+
onAlertEnabledChanged(cue: AudioCue): Event<void>;
2526

2627
playSound(cue: Sound, allowManyInParallel?: boolean): Promise<void>;
2728
playAudioCueLoop(cue: AudioCue, milliseconds: number): IDisposable;
@@ -235,6 +236,10 @@ export class AudioCueService extends Disposable implements IAudioCueService {
235236
public onEnabledChanged(cue: AudioCue): Event<void> {
236237
return Event.fromObservableLight(this.isCueEnabledCache.get({ cue }));
237238
}
239+
240+
public onAlertEnabledChanged(cue: AudioCue): Event<void> {
241+
return Event.fromObservableLight(this.isAlertEnabledCache.get({ cue }));
242+
}
238243
}
239244

240245

src/vs/workbench/contrib/audioCues/browser/audioCueLineFeatureContribution.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export class AudioCueLineFeatureContribution
3737
() => this.audioCueService.isCueEnabled(cue)
3838
));
3939

40+
private readonly isAlertEnabledCache = new CachedFunction<AudioCue, IObservable<boolean>>((cue) => observableFromEvent(
41+
this.audioCueService.onAlertEnabledChanged(cue),
42+
() => this.audioCueService.isAlertEnabled(cue)
43+
));
44+
4045
constructor(
4146
@IEditorService private readonly editorService: IEditorService,
4247
@IInstantiationService private readonly instantiationService: IInstantiationService,
@@ -47,7 +52,7 @@ export class AudioCueLineFeatureContribution
4752

4853
const someAudioCueFeatureIsEnabled = derived(
4954
(reader) => /** @description someAudioCueFeatureIsEnabled */ this.features.some((feature) =>
50-
this.isEnabledCache.get(feature.audioCue).read(reader)
55+
this.isEnabledCache.get(feature.audioCue).read(reader) || this.isAlertEnabledCache.get(feature.audioCue).read(reader)
5156
)
5257
);
5358

@@ -116,7 +121,7 @@ export class AudioCueLineFeatureContribution
116121
const isFeaturePresent = derivedOpts(
117122
{ debugName: `isPresentInLine:${feature.audioCue.name}` },
118123
(reader) => {
119-
if (!this.isEnabledCache.get(feature.audioCue).read(reader)) {
124+
if (!this.isEnabledCache.get(feature.audioCue).read(reader) && !this.isAlertEnabledCache.get(feature.audioCue).read(reader)) {
120125
return false;
121126
}
122127
const position = debouncedPosition.read(reader);

0 commit comments

Comments
 (0)