Skip to content

Commit d6885f6

Browse files
authored
Use const enum over const for search command IDs (microsoft#203757)
Fixes microsoft#190249
1 parent b9511a9 commit d6885f6

14 files changed

+208
-205
lines changed

src/vs/workbench/contrib/search/browser/search.contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ quickAccessRegistry.registerQuickAccessProvider({
121121
prefix: SymbolsQuickAccessProvider.PREFIX,
122122
placeholder: nls.localize('symbolsQuickAccessPlaceholder', "Type the name of a symbol to open."),
123123
contextKey: 'inWorkspaceSymbolsPicker',
124-
helpEntries: [{ description: nls.localize('symbolsQuickAccess', "Go to Symbol in Workspace"), commandId: Constants.ShowAllSymbolsActionId }]
124+
helpEntries: [{ description: nls.localize('symbolsQuickAccess', "Go to Symbol in Workspace"), commandId: Constants.SearchCommandIds.ShowAllSymbolsActionId }]
125125
});
126126

127127
quickAccessRegistry.registerQuickAccessProvider({
@@ -132,7 +132,7 @@ quickAccessRegistry.registerQuickAccessProvider({
132132
helpEntries: [
133133
{
134134
description: nls.localize('textSearchPickerHelp', "Search for Text (Experimental)"),
135-
commandId: Constants.QuickTextSearchActionId,
135+
commandId: Constants.SearchCommandIds.QuickTextSearchActionId,
136136
commandCenterOrder: 65,
137137
}
138138
]

src/vs/workbench/contrib/search/browser/searchActionsCopy.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ registerAction2(class CopyMatchCommandAction extends Action2 {
2121
constructor(
2222
) {
2323
super({
24-
id: Constants.CopyMatchCommandId,
24+
id: Constants.SearchCommandIds.CopyMatchCommandId,
2525
title: {
2626
value: nls.localize('copyMatchLabel', "Copy"),
2727
original: 'Copy'
2828
},
2929
category,
3030
keybinding: {
3131
weight: KeybindingWeight.WorkbenchContrib,
32-
when: Constants.FileMatchOrMatchFocusKey,
32+
when: Constants.SearchContext.FileMatchOrMatchFocusKey,
3333
primary: KeyMod.CtrlCmd | KeyCode.KeyC,
3434
},
3535
menu: [{
3636
id: MenuId.SearchContext,
37-
when: Constants.FileMatchOrMatchFocusKey,
37+
when: Constants.SearchContext.FileMatchOrMatchFocusKey,
3838
group: 'search_2',
3939
order: 1
4040
}]
@@ -52,23 +52,23 @@ registerAction2(class CopyPathCommandAction extends Action2 {
5252
constructor(
5353
) {
5454
super({
55-
id: Constants.CopyPathCommandId,
55+
id: Constants.SearchCommandIds.CopyPathCommandId,
5656
title: {
5757
value: nls.localize('copyPathLabel', "Copy Path"),
5858
original: 'Copy Path'
5959
},
6060
category,
6161
keybinding: {
6262
weight: KeybindingWeight.WorkbenchContrib,
63-
when: Constants.FileMatchOrFolderMatchWithResourceFocusKey,
63+
when: Constants.SearchContext.FileMatchOrFolderMatchWithResourceFocusKey,
6464
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KeyC,
6565
win: {
6666
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KeyC
6767
},
6868
},
6969
menu: [{
7070
id: MenuId.SearchContext,
71-
when: Constants.FileMatchOrFolderMatchWithResourceFocusKey,
71+
when: Constants.SearchContext.FileMatchOrFolderMatchWithResourceFocusKey,
7272
group: 'search_2',
7373
order: 2
7474
}]
@@ -86,15 +86,15 @@ registerAction2(class CopyAllCommandAction extends Action2 {
8686
constructor(
8787
) {
8888
super({
89-
id: Constants.CopyAllCommandId,
89+
id: Constants.SearchCommandIds.CopyAllCommandId,
9090
title: {
9191
value: nls.localize('copyAllLabel', "Copy All"),
9292
original: 'Copy All'
9393
},
9494
category,
9595
menu: [{
9696
id: MenuId.SearchContext,
97-
when: Constants.HasSearchResults,
97+
when: Constants.SearchContext.HasSearchResults,
9898
group: 'search_2',
9999
order: 3
100100
}]

src/vs/workbench/contrib/search/browser/searchActionsFind.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,23 @@ export interface IFindInFilesArgs {
5454
registerAction2(class RestrictSearchToFolderAction extends Action2 {
5555
constructor() {
5656
super({
57-
id: Constants.RestrictSearchToFolderId,
57+
id: Constants.SearchCommandIds.RestrictSearchToFolderId,
5858
title: {
5959
value: nls.localize('restrictResultsToFolder', "Restrict Search to Folder"),
6060
original: 'Restrict Search to Folder'
6161
},
6262
category,
6363
keybinding: {
6464
weight: KeybindingWeight.WorkbenchContrib,
65-
when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.ResourceFolderFocusKey),
65+
when: ContextKeyExpr.and(Constants.SearchContext.SearchViewVisibleKey, Constants.SearchContext.ResourceFolderFocusKey),
6666
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KeyF,
6767
},
6868
menu: [
6969
{
7070
id: MenuId.SearchContext,
7171
group: 'search',
7272
order: 3,
73-
when: ContextKeyExpr.and(Constants.ResourceFolderFocusKey)
73+
when: ContextKeyExpr.and(Constants.SearchContext.ResourceFolderFocusKey)
7474
}
7575
]
7676
});
@@ -83,7 +83,7 @@ registerAction2(class RestrictSearchToFolderAction extends Action2 {
8383
registerAction2(class ExcludeFolderFromSearchAction extends Action2 {
8484
constructor() {
8585
super({
86-
id: Constants.ExcludeFolderFromSearchId,
86+
id: Constants.SearchCommandIds.ExcludeFolderFromSearchId,
8787
title: {
8888
value: nls.localize('excludeFolderFromSearch', "Exclude Folder from Search"),
8989
original: 'Exclude Folder from Search'
@@ -94,7 +94,7 @@ registerAction2(class ExcludeFolderFromSearchAction extends Action2 {
9494
id: MenuId.SearchContext,
9595
group: 'search',
9696
order: 4,
97-
when: ContextKeyExpr.and(Constants.ResourceFolderFocusKey)
97+
when: ContextKeyExpr.and(Constants.SearchContext.ResourceFolderFocusKey)
9898
}
9999
]
100100
});
@@ -109,15 +109,15 @@ registerAction2(class RevealInSideBarForSearchResultsAction extends Action2 {
109109
constructor(
110110
) {
111111
super({
112-
id: Constants.RevealInSideBarForSearchResults,
112+
id: Constants.SearchCommandIds.RevealInSideBarForSearchResults,
113113
title: {
114114
value: nls.localize('revealInSideBar', "Reveal in Explorer View"),
115115
original: 'Reveal in Explorer View'
116116
},
117117
category,
118118
menu: [{
119119
id: MenuId.SearchContext,
120-
when: ContextKeyExpr.and(Constants.FileFocusKey, Constants.HasSearchResults),
120+
when: ContextKeyExpr.and(Constants.SearchContext.FileFocusKey, Constants.SearchContext.HasSearchResults),
121121
group: 'search_3',
122122
order: 1
123123
}]
@@ -167,7 +167,7 @@ registerAction2(class FindInFilesAction extends Action2 {
167167
constructor(
168168
) {
169169
super({
170-
id: Constants.FindInFilesActionId,
170+
id: Constants.SearchCommandIds.FindInFilesActionId,
171171
title: {
172172
value: nls.localize('findInFiles', "Find in Files"),
173173
mnemonicTitle: nls.localize({ key: 'miFindInFiles', comment: ['&& denotes a mnemonic'] }, "Find &&in Files"),
@@ -221,7 +221,7 @@ registerAction2(class FindInFolderAction extends Action2 {
221221
// from explorer
222222
constructor() {
223223
super({
224-
id: Constants.FindInFolderId,
224+
id: Constants.SearchCommandIds.FindInFolderId,
225225
title: {
226226
value: nls.localize('findInFolder', "Find in Folder..."),
227227
original: 'Find in Folder...'
@@ -251,7 +251,7 @@ registerAction2(class FindInWorkspaceAction extends Action2 {
251251
// from explorer
252252
constructor() {
253253
super({
254-
id: Constants.FindInWorkspaceId,
254+
id: Constants.SearchCommandIds.FindInWorkspaceId,
255255
title: {
256256
value: nls.localize('findInWorkspace', "Find in Workspace..."),
257257
original: 'Find in Workspace...'

0 commit comments

Comments
 (0)