Skip to content

Commit a479a5a

Browse files
committed
Use a const enum for keybindings weights
1 parent 75a9a1f commit a479a5a

72 files changed

Lines changed: 357 additions & 357 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { registerEditorCommand, ICommandOptions, EditorCommand, Command } from '
1616
import { IColumnSelectResult, ColumnSelection } from 'vs/editor/common/controller/cursorColumnSelection';
1717
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
1818
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
19-
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
19+
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
2020
import H = editorCommon.Handler;
2121
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
2222
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
@@ -27,7 +27,7 @@ import { DeleteOperations } from 'vs/editor/common/controller/cursorDeleteOperat
2727
import { VerticalRevealType } from 'vs/editor/common/view/viewEvents';
2828
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
2929

30-
const CORE_WEIGHT = KeybindingsRegistry.WEIGHT.editorCore();
30+
const CORE_WEIGHT = KeybindingWeight.EditorCore;
3131

3232
export abstract class CoreEditorCommand extends EditorCommand {
3333
public runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, args: any): void {

src/vs/editor/browser/widget/diffReview.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
3030
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
3131
import { ITextModel, TextModelResolvedOptions } from 'vs/editor/common/model';
3232
import { ViewLineRenderingData } from 'vs/editor/common/viewModel/viewModel';
33-
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
33+
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
3434

3535
const DIFF_LINES_PADDING = 3;
3636

@@ -812,7 +812,7 @@ class DiffReviewNext extends EditorAction {
812812
kbOpts: {
813813
kbExpr: null,
814814
primary: KeyCode.F7,
815-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
815+
weight: KeybindingWeight.EditorContrib
816816
}
817817
});
818818
}
@@ -835,7 +835,7 @@ class DiffReviewPrev extends EditorAction {
835835
kbOpts: {
836836
kbExpr: null,
837837
primary: KeyMod.Shift | KeyCode.F7,
838-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
838+
weight: KeybindingWeight.EditorContrib
839839
}
840840
});
841841
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
2222
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
2323
import { registerColor } from 'vs/platform/theme/common/colorRegistry';
2424
import { TrackedRangeStickiness, IModelDeltaDecoration, OverviewRulerLane } from 'vs/editor/common/model';
25-
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
25+
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
2626

2727
const overviewRulerBracketMatchForeground = registerColor('editorOverviewRuler.bracketMatchForeground', { dark: '#A0A0A0', light: '#A0A0A0', hc: '#A0A0A0' }, nls.localize('overviewRulerBracketMatchForeground', 'Overview ruler marker color for matching brackets.'));
2828

@@ -36,7 +36,7 @@ class JumpToBracketAction extends EditorAction {
3636
kbOpts: {
3737
kbExpr: EditorContextKeys.editorTextFocus,
3838
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKSLASH,
39-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
39+
weight: KeybindingWeight.EditorContrib
4040
}
4141
});
4242
}

src/vs/editor/contrib/caretOperations/transpose.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { registerEditorAction, EditorAction, ServicesAccessor } from 'vs/editor/
1515
import { ReplaceCommand } from 'vs/editor/common/commands/replaceCommand';
1616
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
1717
import { ITextModel } from 'vs/editor/common/model';
18-
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
18+
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
1919

2020
class TransposeLettersAction extends EditorAction {
2121

@@ -69,7 +69,7 @@ class TransposeLettersAction extends EditorAction {
6969
mac: {
7070
primary: KeyMod.WinCtrl | KeyCode.KEY_T
7171
},
72-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
72+
weight: KeybindingWeight.EditorContrib
7373
}
7474
});
7575
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { registerEditorAction, IActionOptions, EditorAction, ICommandKeybindings
1616
import { CopyOptions } from 'vs/editor/browser/controller/textAreaInput';
1717
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
1818
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
19-
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
19+
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
2020

2121
const CLIPBOARD_CONTEXT_MENU_GROUP = '9_cutcopypaste';
2222

@@ -64,7 +64,7 @@ class ExecCommandCutAction extends ExecCommandAction {
6464
kbExpr: EditorContextKeys.textInputFocus,
6565
primary: KeyMod.CtrlCmd | KeyCode.KEY_X,
6666
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_X, secondary: [KeyMod.Shift | KeyCode.Delete] },
67-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
67+
weight: KeybindingWeight.EditorContrib
6868
};
6969
// Do not bind cut keybindings in the browser,
7070
// since browsers do that for us and it avoids security prompts
@@ -102,7 +102,7 @@ class ExecCommandCopyAction extends ExecCommandAction {
102102
kbExpr: EditorContextKeys.textInputFocus,
103103
primary: KeyMod.CtrlCmd | KeyCode.KEY_C,
104104
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_C, secondary: [KeyMod.CtrlCmd | KeyCode.Insert] },
105-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
105+
weight: KeybindingWeight.EditorContrib
106106
};
107107
// Do not bind copy keybindings in the browser,
108108
// since browsers do that for us and it avoids security prompts
@@ -141,7 +141,7 @@ class ExecCommandPasteAction extends ExecCommandAction {
141141
kbExpr: EditorContextKeys.textInputFocus,
142142
primary: KeyMod.CtrlCmd | KeyCode.KEY_V,
143143
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_V, secondary: [KeyMod.Shift | KeyCode.Insert] },
144-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
144+
weight: KeybindingWeight.EditorContrib
145145
};
146146
// Do not bind paste keybindings in the browser,
147147
// since browsers do that for us and it avoids security prompts
@@ -174,7 +174,7 @@ class ExecCommandCopyWithSyntaxHighlightingAction extends ExecCommandAction {
174174
kbOpts: {
175175
kbExpr: EditorContextKeys.textInputFocus,
176176
primary: null,
177-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
177+
weight: KeybindingWeight.EditorContrib
178178
}
179179
});
180180
}

src/vs/editor/contrib/codeAction/codeActionCommands.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { CodeActionModel, CodeActionsComputeEvent, SUPPORTED_CODE_ACTIONS } from
2626
import { CodeActionAutoApply, CodeActionFilter, CodeActionKind } from './codeActionTrigger';
2727
import { CodeActionContextMenu } from './codeActionWidget';
2828
import { LightBulbWidget } from './lightBulbWidget';
29-
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
29+
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
3030

3131
function contextKeyForSupportedActions(kind: CodeActionKind) {
3232
return ContextKeyExpr.regex(
@@ -194,7 +194,7 @@ export class QuickFixAction extends EditorAction {
194194
kbOpts: {
195195
kbExpr: EditorContextKeys.editorTextFocus,
196196
primary: KeyMod.CtrlCmd | KeyCode.US_DOT,
197-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
197+
weight: KeybindingWeight.EditorContrib
198198
}
199199
});
200200
}
@@ -275,7 +275,7 @@ export class RefactorAction extends EditorAction {
275275
mac: {
276276
primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KEY_R
277277
},
278-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
278+
weight: KeybindingWeight.EditorContrib
279279
},
280280
menuOpts: {
281281
group: '1_modification',
@@ -339,7 +339,7 @@ export class OrganizeImportsAction extends EditorAction {
339339
kbOpts: {
340340
kbExpr: EditorContextKeys.editorTextFocus,
341341
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_O,
342-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
342+
weight: KeybindingWeight.EditorContrib
343343
}
344344
});
345345
}

src/vs/editor/contrib/comment/comment.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { registerEditorAction, IActionOptions, EditorAction, ServicesAccessor }
1212
import { BlockCommentCommand } from './blockCommentCommand';
1313
import { LineCommentCommand, Type } from './lineCommentCommand';
1414
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
15-
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
15+
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
1616

1717
abstract class CommentLineAction extends EditorAction {
1818

@@ -54,7 +54,7 @@ class ToggleCommentLineAction extends CommentLineAction {
5454
kbOpts: {
5555
kbExpr: EditorContextKeys.editorTextFocus,
5656
primary: KeyMod.CtrlCmd | KeyCode.US_SLASH,
57-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
57+
weight: KeybindingWeight.EditorContrib
5858
}
5959
});
6060
}
@@ -70,7 +70,7 @@ class AddLineCommentAction extends CommentLineAction {
7070
kbOpts: {
7171
kbExpr: EditorContextKeys.editorTextFocus,
7272
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_C),
73-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
73+
weight: KeybindingWeight.EditorContrib
7474
}
7575
});
7676
}
@@ -86,7 +86,7 @@ class RemoveLineCommentAction extends CommentLineAction {
8686
kbOpts: {
8787
kbExpr: EditorContextKeys.editorTextFocus,
8888
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_U),
89-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
89+
weight: KeybindingWeight.EditorContrib
9090
}
9191
});
9292
}
@@ -104,7 +104,7 @@ class BlockCommentAction extends EditorAction {
104104
kbExpr: EditorContextKeys.editorTextFocus,
105105
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_A,
106106
linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A },
107-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
107+
weight: KeybindingWeight.EditorContrib
108108
}
109109
});
110110
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { IEditorContribution, IScrollEvent, ScrollType } from 'vs/editor/common/
2020
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
2121
import { registerEditorAction, registerEditorContribution, ServicesAccessor, EditorAction } from 'vs/editor/browser/editorExtensions';
2222
import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser';
23-
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
23+
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
2424

2525
export interface IPosition {
2626
x: number;
@@ -229,7 +229,7 @@ class ShowContextMenu extends EditorAction {
229229
kbOpts: {
230230
kbExpr: EditorContextKeys.textInputFocus,
231231
primary: KeyMod.Shift | KeyCode.F10,
232-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
232+
weight: KeybindingWeight.EditorContrib
233233
}
234234
});
235235
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
1212
import { IEditorContribution, ScrollType } from 'vs/editor/common/editorCommon';
1313
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
1414
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
15-
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
15+
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
1616

1717
class CursorState {
1818
readonly selections: Selection[];
@@ -120,7 +120,7 @@ export class CursorUndo extends EditorAction {
120120
kbOpts: {
121121
kbExpr: EditorContextKeys.textInputFocus,
122122
primary: KeyMod.CtrlCmd | KeyCode.KEY_U,
123-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
123+
weight: KeybindingWeight.EditorContrib
124124
}
125125
});
126126
}

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
2323
import { FindWidget, IFindController } from 'vs/editor/contrib/find/findWidget';
2424
import { FindOptionsWidget } from 'vs/editor/contrib/find/findOptionsWidget';
2525
import { IThemeService } from 'vs/platform/theme/common/themeService';
26-
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
26+
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
2727
import { optional } from 'vs/platform/instantiation/common/instantiation';
2828

2929
export function getSelectionSearchString(editor: ICodeEditor): string {
@@ -387,7 +387,7 @@ export class StartFindAction extends EditorAction {
387387
kbOpts: {
388388
kbExpr: null,
389389
primary: KeyMod.CtrlCmd | KeyCode.KEY_F,
390-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
390+
weight: KeybindingWeight.EditorContrib
391391
}
392392
});
393393
}
@@ -420,7 +420,7 @@ export class StartFindWithSelectionAction extends EditorAction {
420420
mac: {
421421
primary: KeyMod.CtrlCmd | KeyCode.KEY_E,
422422
},
423-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
423+
weight: KeybindingWeight.EditorContrib
424424
}
425425
});
426426
}
@@ -470,7 +470,7 @@ export class NextMatchFindAction extends MatchFindAction {
470470
kbExpr: EditorContextKeys.focus,
471471
primary: KeyCode.F3,
472472
mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_G, secondary: [KeyCode.F3] },
473-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
473+
weight: KeybindingWeight.EditorContrib
474474
}
475475
});
476476
}
@@ -492,7 +492,7 @@ export class PreviousMatchFindAction extends MatchFindAction {
492492
kbExpr: EditorContextKeys.focus,
493493
primary: KeyMod.Shift | KeyCode.F3,
494494
mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_G, secondary: [KeyMod.Shift | KeyCode.F3] },
495-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
495+
weight: KeybindingWeight.EditorContrib
496496
}
497497
});
498498
}
@@ -538,7 +538,7 @@ export class NextSelectionMatchFindAction extends SelectionMatchFindAction {
538538
kbOpts: {
539539
kbExpr: EditorContextKeys.focus,
540540
primary: KeyMod.CtrlCmd | KeyCode.F3,
541-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
541+
weight: KeybindingWeight.EditorContrib
542542
}
543543
});
544544
}
@@ -559,7 +559,7 @@ export class PreviousSelectionMatchFindAction extends SelectionMatchFindAction {
559559
kbOpts: {
560560
kbExpr: EditorContextKeys.focus,
561561
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F3,
562-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
562+
weight: KeybindingWeight.EditorContrib
563563
}
564564
});
565565
}
@@ -581,7 +581,7 @@ export class StartFindReplaceAction extends EditorAction {
581581
kbExpr: null,
582582
primary: KeyMod.CtrlCmd | KeyCode.KEY_H,
583583
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_F },
584-
weight: KeybindingsRegistry.WEIGHT.editorContrib()
584+
weight: KeybindingWeight.EditorContrib
585585
}
586586
});
587587
}
@@ -631,7 +631,7 @@ registerEditorCommand(new FindCommand({
631631
precondition: CONTEXT_FIND_WIDGET_VISIBLE,
632632
handler: x => x.closeFindWidget(),
633633
kbOpts: {
634-
weight: KeybindingsRegistry.WEIGHT.editorContrib() + 5,
634+
weight: KeybindingWeight.EditorContrib + 5,
635635
kbExpr: EditorContextKeys.focus,
636636
primary: KeyCode.Escape,
637637
secondary: [KeyMod.Shift | KeyCode.Escape]
@@ -643,7 +643,7 @@ registerEditorCommand(new FindCommand({
643643
precondition: null,
644644
handler: x => x.toggleCaseSensitive(),
645645
kbOpts: {
646-
weight: KeybindingsRegistry.WEIGHT.editorContrib() + 5,
646+
weight: KeybindingWeight.EditorContrib + 5,
647647
kbExpr: EditorContextKeys.focus,
648648
primary: ToggleCaseSensitiveKeybinding.primary,
649649
mac: ToggleCaseSensitiveKeybinding.mac,
@@ -657,7 +657,7 @@ registerEditorCommand(new FindCommand({
657657
precondition: null,
658658
handler: x => x.toggleWholeWords(),
659659
kbOpts: {
660-
weight: KeybindingsRegistry.WEIGHT.editorContrib() + 5,
660+
weight: KeybindingWeight.EditorContrib + 5,
661661
kbExpr: EditorContextKeys.focus,
662662
primary: ToggleWholeWordKeybinding.primary,
663663
mac: ToggleWholeWordKeybinding.mac,
@@ -671,7 +671,7 @@ registerEditorCommand(new FindCommand({
671671
precondition: null,
672672
handler: x => x.toggleRegex(),
673673
kbOpts: {
674-
weight: KeybindingsRegistry.WEIGHT.editorContrib() + 5,
674+
weight: KeybindingWeight.EditorContrib + 5,
675675
kbExpr: EditorContextKeys.focus,
676676
primary: ToggleRegexKeybinding.primary,
677677
mac: ToggleRegexKeybinding.mac,
@@ -685,7 +685,7 @@ registerEditorCommand(new FindCommand({
685685
precondition: null,
686686
handler: x => x.toggleSearchScope(),
687687
kbOpts: {
688-
weight: KeybindingsRegistry.WEIGHT.editorContrib() + 5,
688+
weight: KeybindingWeight.EditorContrib + 5,
689689
kbExpr: EditorContextKeys.focus,
690690
primary: ToggleSearchScopeKeybinding.primary,
691691
mac: ToggleSearchScopeKeybinding.mac,
@@ -699,7 +699,7 @@ registerEditorCommand(new FindCommand({
699699
precondition: CONTEXT_FIND_WIDGET_VISIBLE,
700700
handler: x => x.replace(),
701701
kbOpts: {
702-
weight: KeybindingsRegistry.WEIGHT.editorContrib() + 5,
702+
weight: KeybindingWeight.EditorContrib + 5,
703703
kbExpr: EditorContextKeys.focus,
704704
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_1
705705
}
@@ -710,7 +710,7 @@ registerEditorCommand(new FindCommand({
710710
precondition: CONTEXT_FIND_WIDGET_VISIBLE,
711711
handler: x => x.replaceAll(),
712712
kbOpts: {
713-
weight: KeybindingsRegistry.WEIGHT.editorContrib() + 5,
713+
weight: KeybindingWeight.EditorContrib + 5,
714714
kbExpr: EditorContextKeys.focus,
715715
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Enter
716716
}
@@ -721,7 +721,7 @@ registerEditorCommand(new FindCommand({
721721
precondition: CONTEXT_FIND_WIDGET_VISIBLE,
722722
handler: x => x.selectAllMatches(),
723723
kbOpts: {
724-
weight: KeybindingsRegistry.WEIGHT.editorContrib() + 5,
724+
weight: KeybindingWeight.EditorContrib + 5,
725725
kbExpr: EditorContextKeys.focus,
726726
primary: KeyMod.Alt | KeyCode.Enter
727727
}

0 commit comments

Comments
 (0)