Skip to content

Commit 0787bf6

Browse files
committed
Use undefined instead of null | undefined for commands
1 parent 653edff commit 0787bf6

33 files changed

Lines changed: 150 additions & 150 deletions

File tree

src/vs/editor/browser/controller/coreCommands.ts

Lines changed: 51 additions & 51 deletions
Large diffs are not rendered by default.

src/vs/editor/browser/editorExtensions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ export interface ICommandMenubarOptions {
4040
}
4141
export interface ICommandOptions {
4242
id: string;
43-
precondition: ContextKeyExpr | null;
44-
kbOpts?: ICommandKeybindingsOptions | null;
43+
precondition: ContextKeyExpr | undefined;
44+
kbOpts?: ICommandKeybindingsOptions;
4545
description?: ICommandHandlerDescription;
4646
menubarOpts?: ICommandMenubarOptions;
4747
}
4848
export abstract class Command {
4949
public readonly id: string;
50-
public readonly precondition: ContextKeyExpr | null;
51-
private readonly _kbOpts: ICommandKeybindingsOptions | null | undefined;
52-
private readonly _menubarOpts: ICommandMenubarOptions | null | undefined;
53-
private readonly _description: ICommandHandlerDescription | null | undefined;
50+
public readonly precondition: ContextKeyExpr | undefined;
51+
private readonly _kbOpts: ICommandKeybindingsOptions | undefined;
52+
private readonly _menubarOpts: ICommandMenubarOptions | undefined;
53+
private readonly _description: ICommandHandlerDescription | undefined;
5454

5555
constructor(opts: ICommandOptions) {
5656
this.id = opts.id;

src/vs/editor/contrib/bracketMatching/bracketMatching.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class JumpToBracketAction extends EditorAction {
3131
id: 'editor.action.jumpToBracket',
3232
label: nls.localize('smartSelect.jumpBracket', "Go to Bracket"),
3333
alias: 'Go to Bracket',
34-
precondition: null,
34+
precondition: undefined,
3535
kbOpts: {
3636
kbExpr: EditorContextKeys.editorTextFocus,
3737
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKSLASH,
@@ -55,7 +55,7 @@ class SelectToBracketAction extends EditorAction {
5555
id: 'editor.action.selectToBracket',
5656
label: nls.localize('smartSelect.selectToBracket', "Select to Bracket"),
5757
alias: 'Select to Bracket',
58-
precondition: null
58+
precondition: undefined
5959
});
6060
}
6161

src/vs/editor/contrib/clipboard/clipboard.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ abstract class ExecCommandAction extends EditorAction {
5959
class ExecCommandCutAction extends ExecCommandAction {
6060

6161
constructor() {
62-
let kbOpts: ICommandKeybindingsOptions | null = {
62+
let kbOpts: ICommandKeybindingsOptions | undefined = {
6363
kbExpr: EditorContextKeys.textInputFocus,
6464
primary: KeyMod.CtrlCmd | KeyCode.KEY_X,
6565
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_X, secondary: [KeyMod.Shift | KeyCode.Delete] },
@@ -68,7 +68,7 @@ class ExecCommandCutAction extends ExecCommandAction {
6868
// Do not bind cut keybindings in the browser,
6969
// since browsers do that for us and it avoids security prompts
7070
if (!platform.isNative) {
71-
kbOpts = null;
71+
kbOpts = undefined;
7272
}
7373
super('cut', {
7474
id: 'editor.action.clipboardCutAction',
@@ -107,7 +107,7 @@ class ExecCommandCutAction extends ExecCommandAction {
107107
class ExecCommandCopyAction extends ExecCommandAction {
108108

109109
constructor() {
110-
let kbOpts: ICommandKeybindingsOptions | null = {
110+
let kbOpts: ICommandKeybindingsOptions | undefined = {
111111
kbExpr: EditorContextKeys.textInputFocus,
112112
primary: KeyMod.CtrlCmd | KeyCode.KEY_C,
113113
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_C, secondary: [KeyMod.CtrlCmd | KeyCode.Insert] },
@@ -116,14 +116,14 @@ class ExecCommandCopyAction extends ExecCommandAction {
116116
// Do not bind copy keybindings in the browser,
117117
// since browsers do that for us and it avoids security prompts
118118
if (!platform.isNative) {
119-
kbOpts = null;
119+
kbOpts = undefined;
120120
}
121121

122122
super('copy', {
123123
id: 'editor.action.clipboardCopyAction',
124124
label: nls.localize('actions.clipboard.copyLabel', "Copy"),
125125
alias: 'Copy',
126-
precondition: null,
126+
precondition: undefined,
127127
kbOpts: kbOpts,
128128
menuOpts: {
129129
group: CLIPBOARD_CONTEXT_MENU_GROUP,
@@ -162,7 +162,7 @@ class ExecCommandCopyAction extends ExecCommandAction {
162162
class ExecCommandPasteAction extends ExecCommandAction {
163163

164164
constructor() {
165-
let kbOpts: ICommandKeybindingsOptions | null = {
165+
let kbOpts: ICommandKeybindingsOptions | undefined = {
166166
kbExpr: EditorContextKeys.textInputFocus,
167167
primary: KeyMod.CtrlCmd | KeyCode.KEY_V,
168168
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_V, secondary: [KeyMod.Shift | KeyCode.Insert] },
@@ -171,7 +171,7 @@ class ExecCommandPasteAction extends ExecCommandAction {
171171
// Do not bind paste keybindings in the browser,
172172
// since browsers do that for us and it avoids security prompts
173173
if (!platform.isNative) {
174-
kbOpts = null;
174+
kbOpts = undefined;
175175
}
176176

177177
super('paste', {
@@ -201,7 +201,7 @@ class ExecCommandCopyWithSyntaxHighlightingAction extends ExecCommandAction {
201201
id: 'editor.action.clipboardCopyWithSyntaxHighlightingAction',
202202
label: nls.localize('actions.clipboard.copyWithSyntaxHighlightingLabel', "Copy With Syntax Highlighting"),
203203
alias: 'Copy With Syntax Highlighting',
204-
precondition: null,
204+
precondition: undefined,
205205
kbOpts: {
206206
kbExpr: EditorContextKeys.textInputFocus,
207207
primary: 0,

src/vs/editor/contrib/contextmenu/contextmenu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class ShowContextMenu extends EditorAction {
228228
id: 'editor.action.showContextMenu',
229229
label: nls.localize('action.showContextMenu.label', "Show Editor Context Menu"),
230230
alias: 'Show Editor Context Menu',
231-
precondition: null,
231+
precondition: undefined,
232232
kbOpts: {
233233
kbExpr: EditorContextKeys.textInputFocus,
234234
primary: KeyMod.Shift | KeyCode.F10,

src/vs/editor/contrib/cursorUndo/cursorUndo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class CursorUndo extends EditorAction {
119119
id: 'cursorUndo',
120120
label: nls.localize('cursor.undo', "Soft Undo"),
121121
alias: 'Soft Undo',
122-
precondition: null,
122+
precondition: undefined,
123123
kbOpts: {
124124
kbExpr: EditorContextKeys.textInputFocus,
125125
primary: KeyMod.CtrlCmd | KeyCode.KEY_U,

src/vs/editor/contrib/find/findController.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ export class StartFindAction extends EditorAction {
422422
id: FIND_IDS.StartFindAction,
423423
label: nls.localize('startFindAction', "Find"),
424424
alias: 'Find',
425-
precondition: null,
425+
precondition: undefined,
426426
kbOpts: {
427427
kbExpr: null,
428428
primary: KeyMod.CtrlCmd | KeyCode.KEY_F,
@@ -459,7 +459,7 @@ export class StartFindWithSelectionAction extends EditorAction {
459459
id: FIND_IDS.StartFindWithSelection,
460460
label: nls.localize('startFindWithSelectionAction', "Find With Selection"),
461461
alias: 'Find With Selection',
462-
precondition: null,
462+
precondition: undefined,
463463
kbOpts: {
464464
kbExpr: null,
465465
primary: 0,
@@ -513,7 +513,7 @@ export class NextMatchFindAction extends MatchFindAction {
513513
id: FIND_IDS.NextMatchFindAction,
514514
label: nls.localize('findNextMatchAction', "Find Next"),
515515
alias: 'Find Next',
516-
precondition: null,
516+
precondition: undefined,
517517
kbOpts: {
518518
kbExpr: EditorContextKeys.focus,
519519
primary: KeyCode.F3,
@@ -535,7 +535,7 @@ export class PreviousMatchFindAction extends MatchFindAction {
535535
id: FIND_IDS.PreviousMatchFindAction,
536536
label: nls.localize('findPreviousMatchAction', "Find Previous"),
537537
alias: 'Find Previous',
538-
precondition: null,
538+
precondition: undefined,
539539
kbOpts: {
540540
kbExpr: EditorContextKeys.focus,
541541
primary: KeyMod.Shift | KeyCode.F3,
@@ -583,7 +583,7 @@ export class NextSelectionMatchFindAction extends SelectionMatchFindAction {
583583
id: FIND_IDS.NextSelectionMatchFindAction,
584584
label: nls.localize('nextSelectionMatchFindAction', "Find Next Selection"),
585585
alias: 'Find Next Selection',
586-
precondition: null,
586+
precondition: undefined,
587587
kbOpts: {
588588
kbExpr: EditorContextKeys.focus,
589589
primary: KeyMod.CtrlCmd | KeyCode.F3,
@@ -604,7 +604,7 @@ export class PreviousSelectionMatchFindAction extends SelectionMatchFindAction {
604604
id: FIND_IDS.PreviousSelectionMatchFindAction,
605605
label: nls.localize('previousSelectionMatchFindAction', "Find Previous Selection"),
606606
alias: 'Find Previous Selection',
607-
precondition: null,
607+
precondition: undefined,
608608
kbOpts: {
609609
kbExpr: EditorContextKeys.focus,
610610
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F3,
@@ -625,7 +625,7 @@ export class StartFindReplaceAction extends EditorAction {
625625
id: FIND_IDS.StartFindReplaceAction,
626626
label: nls.localize('startReplace', "Replace"),
627627
alias: 'Replace',
628-
precondition: null,
628+
precondition: undefined,
629629
kbOpts: {
630630
kbExpr: null,
631631
primary: KeyMod.CtrlCmd | KeyCode.KEY_H,
@@ -704,7 +704,7 @@ registerEditorCommand(new FindCommand({
704704

705705
registerEditorCommand(new FindCommand({
706706
id: FIND_IDS.ToggleCaseSensitiveCommand,
707-
precondition: null,
707+
precondition: undefined,
708708
handler: x => x.toggleCaseSensitive(),
709709
kbOpts: {
710710
weight: KeybindingWeight.EditorContrib + 5,
@@ -718,7 +718,7 @@ registerEditorCommand(new FindCommand({
718718

719719
registerEditorCommand(new FindCommand({
720720
id: FIND_IDS.ToggleWholeWordCommand,
721-
precondition: null,
721+
precondition: undefined,
722722
handler: x => x.toggleWholeWords(),
723723
kbOpts: {
724724
weight: KeybindingWeight.EditorContrib + 5,
@@ -732,7 +732,7 @@ registerEditorCommand(new FindCommand({
732732

733733
registerEditorCommand(new FindCommand({
734734
id: FIND_IDS.ToggleRegexCommand,
735-
precondition: null,
735+
precondition: undefined,
736736
handler: x => x.toggleRegex(),
737737
kbOpts: {
738738
weight: KeybindingWeight.EditorContrib + 5,
@@ -746,7 +746,7 @@ registerEditorCommand(new FindCommand({
746746

747747
registerEditorCommand(new FindCommand({
748748
id: FIND_IDS.ToggleSearchScopeCommand,
749-
precondition: null,
749+
precondition: undefined,
750750
handler: x => x.toggleSearchScope(),
751751
kbOpts: {
752752
weight: KeybindingWeight.EditorContrib + 5,

src/vs/editor/contrib/folding/folding.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ class UnfoldAction extends FoldingAction<FoldingArguments> {
503503
id: 'editor.unfold',
504504
label: nls.localize('unfoldAction.label', "Unfold"),
505505
alias: 'Unfold',
506-
precondition: null,
506+
precondition: undefined,
507507
kbOpts: {
508508
kbExpr: EditorContextKeys.editorTextFocus,
509509
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_CLOSE_SQUARE_BRACKET,
@@ -567,7 +567,7 @@ class UnFoldRecursivelyAction extends FoldingAction<void> {
567567
id: 'editor.unfoldRecursively',
568568
label: nls.localize('unFoldRecursivelyAction.label', "Unfold Recursively"),
569569
alias: 'Unfold Recursively',
570-
precondition: null,
570+
precondition: undefined,
571571
kbOpts: {
572572
kbExpr: EditorContextKeys.editorTextFocus,
573573
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_CLOSE_SQUARE_BRACKET),
@@ -588,7 +588,7 @@ class FoldAction extends FoldingAction<FoldingArguments> {
588588
id: 'editor.fold',
589589
label: nls.localize('foldAction.label', "Fold"),
590590
alias: 'Fold',
591-
precondition: null,
591+
precondition: undefined,
592592
kbOpts: {
593593
kbExpr: EditorContextKeys.editorTextFocus,
594594
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_OPEN_SQUARE_BRACKET,
@@ -652,7 +652,7 @@ class FoldRecursivelyAction extends FoldingAction<void> {
652652
id: 'editor.foldRecursively',
653653
label: nls.localize('foldRecursivelyAction.label', "Fold Recursively"),
654654
alias: 'Fold Recursively',
655-
precondition: null,
655+
precondition: undefined,
656656
kbOpts: {
657657
kbExpr: EditorContextKeys.editorTextFocus,
658658
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_OPEN_SQUARE_BRACKET),
@@ -674,7 +674,7 @@ class FoldAllBlockCommentsAction extends FoldingAction<void> {
674674
id: 'editor.foldAllBlockComments',
675675
label: nls.localize('foldAllBlockComments.label', "Fold All Block Comments"),
676676
alias: 'Fold All Block Comments',
677-
precondition: null,
677+
precondition: undefined,
678678
kbOpts: {
679679
kbExpr: EditorContextKeys.editorTextFocus,
680680
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_SLASH),
@@ -707,7 +707,7 @@ class FoldAllRegionsAction extends FoldingAction<void> {
707707
id: 'editor.foldAllMarkerRegions',
708708
label: nls.localize('foldAllMarkerRegions.label', "Fold All Regions"),
709709
alias: 'Fold All Regions',
710-
precondition: null,
710+
precondition: undefined,
711711
kbOpts: {
712712
kbExpr: EditorContextKeys.editorTextFocus,
713713
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_8),
@@ -740,7 +740,7 @@ class UnfoldAllRegionsAction extends FoldingAction<void> {
740740
id: 'editor.unfoldAllMarkerRegions',
741741
label: nls.localize('unfoldAllMarkerRegions.label', "Unfold All Regions"),
742742
alias: 'Unfold All Regions',
743-
precondition: null,
743+
precondition: undefined,
744744
kbOpts: {
745745
kbExpr: EditorContextKeys.editorTextFocus,
746746
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_9),
@@ -773,7 +773,7 @@ class FoldAllAction extends FoldingAction<void> {
773773
id: 'editor.foldAll',
774774
label: nls.localize('foldAllAction.label', "Fold All"),
775775
alias: 'Fold All',
776-
precondition: null,
776+
precondition: undefined,
777777
kbOpts: {
778778
kbExpr: EditorContextKeys.editorTextFocus,
779779
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_0),
@@ -794,7 +794,7 @@ class UnfoldAllAction extends FoldingAction<void> {
794794
id: 'editor.unfoldAll',
795795
label: nls.localize('unfoldAllAction.label', "Unfold All"),
796796
alias: 'Unfold All',
797-
precondition: null,
797+
precondition: undefined,
798798
kbOpts: {
799799
kbExpr: EditorContextKeys.editorTextFocus,
800800
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_J),
@@ -838,7 +838,7 @@ for (let i = 1; i <= 7; i++) {
838838
id: FoldLevelAction.ID(i),
839839
label: nls.localize('foldLevelAction.label', "Fold Level {0}", i),
840840
alias: `Fold Level ${i}`,
841-
precondition: null,
841+
precondition: undefined,
842842
kbOpts: {
843843
kbExpr: EditorContextKeys.editorTextFocus,
844844
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | (KeyCode.KEY_0 + i)),

src/vs/editor/contrib/fontZoom/fontZoom.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class EditorFontZoomIn extends EditorAction {
1515
id: 'editor.action.fontZoomIn',
1616
label: nls.localize('EditorFontZoomIn.label', "Editor Font Zoom In"),
1717
alias: 'Editor Font Zoom In',
18-
precondition: null
18+
precondition: undefined
1919
});
2020
}
2121

@@ -31,7 +31,7 @@ class EditorFontZoomOut extends EditorAction {
3131
id: 'editor.action.fontZoomOut',
3232
label: nls.localize('EditorFontZoomOut.label', "Editor Font Zoom Out"),
3333
alias: 'Editor Font Zoom Out',
34-
precondition: null
34+
precondition: undefined
3535
});
3636
}
3737

@@ -47,7 +47,7 @@ class EditorFontZoomReset extends EditorAction {
4747
id: 'editor.action.fontZoomReset',
4848
label: nls.localize('EditorFontZoomReset.label', "Editor Font Zoom Reset"),
4949
alias: 'Editor Font Zoom Reset',
50-
precondition: null
50+
precondition: undefined
5151
});
5252
}
5353

src/vs/editor/contrib/goToDefinition/goToDefinitionMouse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
294294

295295
private gotoDefinition(target: IMouseTarget, sideBySide: boolean): Promise<any> {
296296
this.editor.setPosition(target.position!);
297-
const action = new DefinitionAction(new DefinitionActionConfig(sideBySide, false, true, false), { alias: '', label: '', id: '', precondition: null });
297+
const action = new DefinitionAction(new DefinitionActionConfig(sideBySide, false, true, false), { alias: '', label: '', id: '', precondition: undefined });
298298
return this.editor.invokeWithinContext(accessor => action.run(accessor, this.editor));
299299
}
300300

0 commit comments

Comments
 (0)