Skip to content

Commit e7f559c

Browse files
committed
Mark keybindings arrays as readonly
These arrays should not be mutated by callers as it would cause the keybinding service to have unexpected behavior
1 parent d62481b commit e7f559c

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/vs/platform/keybinding/common/abstractKeybindingService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ export abstract class AbstractKeybindingService extends Disposable implements IK
6565
return '';
6666
}
6767

68-
public getDefaultKeybindings(): ResolvedKeybindingItem[] {
68+
public getDefaultKeybindings(): readonly ResolvedKeybindingItem[] {
6969
return this._getResolver().getDefaultKeybindings();
7070
}
7171

72-
public getKeybindings(): ResolvedKeybindingItem[] {
72+
public getKeybindings(): readonly ResolvedKeybindingItem[] {
7373
return this._getResolver().getKeybindings();
7474
}
7575

src/vs/platform/keybinding/common/keybinding.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ export interface IKeybindingService {
8787

8888
getDefaultKeybindingsContent(): string;
8989

90-
getDefaultKeybindings(): ResolvedKeybindingItem[];
90+
getDefaultKeybindings(): readonly ResolvedKeybindingItem[];
9191

92-
getKeybindings(): ResolvedKeybindingItem[];
92+
getKeybindings(): readonly ResolvedKeybindingItem[];
9393

9494
customKeybindingsCount(): number;
9595

src/vs/platform/keybinding/common/keybindingResolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,11 @@ export class KeybindingResolver {
215215
return this._defaultBoundCommands;
216216
}
217217

218-
public getDefaultKeybindings(): ResolvedKeybindingItem[] {
218+
public getDefaultKeybindings(): readonly ResolvedKeybindingItem[] {
219219
return this._defaultKeybindings;
220220
}
221221

222-
public getKeybindings(): ResolvedKeybindingItem[] {
222+
public getKeybindings(): readonly ResolvedKeybindingItem[] {
223223
return this._keybindings;
224224
}
225225

src/vs/workbench/services/keybinding/browser/keybindingService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
517517
);
518518
}
519519

520-
private static _getDefaultKeybindings(defaultKeybindings: ResolvedKeybindingItem[]): string {
520+
private static _getDefaultKeybindings(defaultKeybindings: readonly ResolvedKeybindingItem[]): string {
521521
let out = new OutputBuilder();
522522
out.writeLine('[');
523523

0 commit comments

Comments
 (0)