Skip to content

Commit 8003736

Browse files
fix term crash when bell is false
1 parent ab3d4b7 commit 8003736

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

app/config/schema.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
},
3434
"bell": {
3535
"description": "Supported Options:\n1. 'SOUND' -> Enables the bell as a sound\n2. false: turns off the bell",
36-
"type": "string"
36+
"enum": [
37+
"SOUND",
38+
false
39+
]
3740
},
3841
"bellSound": {
3942
"description": "base64 encoded string of the sound file to use for the bell\nif null, the default bell will be used",
@@ -357,7 +360,10 @@
357360
},
358361
"bell": {
359362
"description": "Supported Options:\n1. 'SOUND' -> Enables the bell as a sound\n2. false: turns off the bell",
360-
"type": "string"
363+
"enum": [
364+
"SOUND",
365+
false
366+
]
361367
},
362368
"bellSound": {
363369
"description": "base64 encoded string of the sound file to use for the bell\nif null, the default bell will be used",

lib/components/term.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ export default class Term extends React.PureComponent<
416416
return !e.catched;
417417
}
418418

419-
setBellSound(bell: string | null, sound: string | null) {
420-
if (bell?.toUpperCase() === 'SOUND') {
419+
setBellSound(bell: 'SOUND' | false, sound: string | null) {
420+
if (bell && bell.toUpperCase() === 'SOUND') {
421421
this.bellSound = sound ? new Audio(sound) : this.defaultBellSound;
422422
} else {
423423
this.bellSound = null;

lib/config.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type profileConfigOptions = {
4646
* 1. 'SOUND' -> Enables the bell as a sound
4747
* 2. false: turns off the bell
4848
*/
49-
bell: string;
49+
bell: 'SOUND' | false;
5050
/**
5151
* base64 encoded string of the sound file to use for the bell
5252
* if null, the default bell will be used

lib/hyper.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export type uiState = Immutable<{
4747
activeUid: string | null;
4848
activityMarkers: Record<string, boolean>;
4949
backgroundColor: string;
50-
bell: string;
50+
bell: 'SOUND' | false;
5151
bellSoundURL: string | null;
5252
bellSound: string | null;
5353
borderColor: string;
@@ -347,7 +347,7 @@ import type {FitAddon} from 'xterm-addon-fit';
347347
import type {SearchAddon} from 'xterm-addon-search';
348348
export type TermProps = {
349349
backgroundColor: string;
350-
bell: string;
350+
bell: 'SOUND' | false;
351351
bellSound: string | null;
352352
bellSoundURL: string | null;
353353
borderColor: string;

lib/reducers/ui.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ const reducer: IUiReducer = (state = initial, action) => {
217217
}
218218

219219
if (allowedBells.has(config.bell)) {
220-
ret.bell = config.bell;
220+
ret.bell = (config.bell as any) === 'false' ? false : config.bell;
221221
}
222222

223223
if (config.bellSoundURL !== state.bellSoundURL) {

0 commit comments

Comments
 (0)