Reduce "export const [...]id" pattern to save on minified code size.

Closes #96672
This commit is contained in:
Jackson Kearl 2020-05-06 10:53:51 -07:00
parent 637b59c7b9
commit 63f167a68b
3 changed files with 33 additions and 31 deletions

View file

@ -5,26 +5,9 @@
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
export const OpenInEditorCommandId = 'search.action.openInEditor';
export const OpenNewEditorCommandId = 'search.action.openNewEditor';
export const OpenNewEditorToSideCommandId = 'search.action.openNewEditorToSide';
export const FocusQueryEditorWidgetCommandId = 'search.action.focusQueryEditorWidget';
export const ToggleSearchEditorCaseSensitiveCommandId = 'toggleSearchEditorCaseSensitive';
export const ToggleSearchEditorWholeWordCommandId = 'toggleSearchEditorWholeWord';
export const ToggleSearchEditorRegexCommandId = 'toggleSearchEditorRegex';
export const ToggleSearchEditorContextLinesCommandId = 'toggleSearchEditorContextLines';
export const IncreaseSearchEditorContextLinesCommandId = 'increaseSearchEditorContextLines';
export const DecreaseSearchEditorContextLinesCommandId = 'decreaseSearchEditorContextLines';
export const RerunSearchEditorSearchCommandId = 'rerunSearchEditorSearch';
export const CleanSearchEditorStateCommandId = 'cleanSearchEditorState';
export const SelectAllSearchEditorMatchesCommandId = 'selectAllSearchEditorMatches';
export const InSearchEditor = new RawContextKey<boolean>('inSearchEditor', false);
export const SearchEditorScheme = 'search-editor';
export const SearchEditorBodyScheme = 'search-editor-body';
export const SearchEditorFindMatchClass = 'seaarchEditorFindMatch';

View file

@ -35,6 +35,24 @@ import { searchRefreshIcon } from 'vs/workbench/contrib/search/browser/searchIco
import { IViewsService } from 'vs/workbench/common/views';
import { getSearchView } from 'vs/workbench/contrib/search/browser/searchActions';
const OpenInEditorCommandId = 'search.action.openInEditor';
const OpenNewEditorToSideCommandId = 'search.action.openNewEditorToSide';
const FocusQueryEditorWidgetCommandId = 'search.action.focusQueryEditorWidget';
const ToggleSearchEditorCaseSensitiveCommandId = 'toggleSearchEditorCaseSensitive';
const ToggleSearchEditorWholeWordCommandId = 'toggleSearchEditorWholeWord';
const ToggleSearchEditorRegexCommandId = 'toggleSearchEditorRegex';
const ToggleSearchEditorContextLinesCommandId = 'toggleSearchEditorContextLines';
const IncreaseSearchEditorContextLinesCommandId = 'increaseSearchEditorContextLines';
const DecreaseSearchEditorContextLinesCommandId = 'decreaseSearchEditorContextLines';
const RerunSearchEditorSearchCommandId = 'rerunSearchEditorSearch';
const CleanSearchEditorStateCommandId = 'cleanSearchEditorState';
const SelectAllSearchEditorMatchesCommandId = 'selectAllSearchEditorMatches';
//#region Editor Descriptior
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
EditorDescriptor.create(
@ -128,28 +146,28 @@ Registry.as<IEditorInputFactoryRegistry>(EditorInputExtensions.EditorInputFactor
//#region Commands
KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({
id: SearchEditorConstants.ToggleSearchEditorCaseSensitiveCommandId,
id: ToggleSearchEditorCaseSensitiveCommandId,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(SearchEditorConstants.InSearchEditor, SearchConstants.SearchInputBoxFocusedKey),
handler: toggleSearchEditorCaseSensitiveCommand
}, ToggleCaseSensitiveKeybinding));
KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({
id: SearchEditorConstants.ToggleSearchEditorWholeWordCommandId,
id: ToggleSearchEditorWholeWordCommandId,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(SearchEditorConstants.InSearchEditor, SearchConstants.SearchInputBoxFocusedKey),
handler: toggleSearchEditorWholeWordCommand
}, ToggleWholeWordKeybinding));
KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({
id: SearchEditorConstants.ToggleSearchEditorRegexCommandId,
id: ToggleSearchEditorRegexCommandId,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(SearchEditorConstants.InSearchEditor, SearchConstants.SearchInputBoxFocusedKey),
handler: toggleSearchEditorRegexCommand
}, ToggleRegexKeybinding));
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: SearchEditorConstants.ToggleSearchEditorContextLinesCommandId,
id: ToggleSearchEditorContextLinesCommandId,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(SearchEditorConstants.InSearchEditor),
handler: toggleSearchEditorContextLinesCommand,
@ -158,7 +176,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: SearchEditorConstants.IncreaseSearchEditorContextLinesCommandId,
id: IncreaseSearchEditorContextLinesCommandId,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(SearchEditorConstants.InSearchEditor),
handler: (accessor: ServicesAccessor) => modifySearchEditorContextLinesCommand(accessor, true),
@ -166,7 +184,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: SearchEditorConstants.DecreaseSearchEditorContextLinesCommandId,
id: DecreaseSearchEditorContextLinesCommandId,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(SearchEditorConstants.InSearchEditor),
handler: (accessor: ServicesAccessor) => modifySearchEditorContextLinesCommand(accessor, false),
@ -174,7 +192,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: SearchEditorConstants.SelectAllSearchEditorMatchesCommandId,
id: SelectAllSearchEditorMatchesCommandId,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(SearchEditorConstants.InSearchEditor),
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_L,
@ -182,7 +200,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
});
CommandsRegistry.registerCommand(
SearchEditorConstants.CleanSearchEditorStateCommandId,
CleanSearchEditorStateCommandId,
(accessor: ServicesAccessor) => {
const activeEditorPane = accessor.get(IEditorService).activeEditorPane;
if (activeEditorPane instanceof SearchEditor) {
@ -203,7 +221,7 @@ registry.registerWorkbenchAction(
registerAction2(class extends Action2 {
constructor() {
super({
id: SearchEditorConstants.OpenInEditorCommandId,
id: OpenInEditorCommandId,
title: localize('search.openResultsInEditor', "Open Results in Editor"),
category,
f1: true,
@ -227,7 +245,7 @@ registerAction2(class extends Action2 {
registerAction2(class extends Action2 {
constructor() {
super({
id: SearchEditorConstants.OpenNewEditorToSideCommandId,
id: OpenNewEditorToSideCommandId,
title: localize('search.openNewEditorToSide', "Open New Search Editor to Side"),
category,
f1: true,
@ -242,7 +260,7 @@ registerAction2(class extends Action2 {
registerAction2(class extends Action2 {
constructor() {
super({
id: SearchEditorConstants.RerunSearchEditorSearchCommandId,
id: RerunSearchEditorSearchCommandId,
title: localize('search.rerunSearchInEditor', "Search Again"),
category,
keybinding: {
@ -274,7 +292,7 @@ registerAction2(class extends Action2 {
registerAction2(class extends Action2 {
constructor() {
super({
id: SearchEditorConstants.FocusQueryEditorWidgetCommandId,
id: FocusQueryEditorWidgetCommandId,
title: localize('search.action.focusQueryEditorWidget', "Focus Search Editor Input"),
category,
menu: {

View file

@ -13,7 +13,6 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati
import { ILabelService } from 'vs/platform/label/common/label';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { SearchResult } from 'vs/workbench/contrib/search/common/searchModel';
import * as Constants from 'vs/workbench/contrib/searchEditor/browser/constants';
import { SearchEditor } from 'vs/workbench/contrib/searchEditor/browser/searchEditor';
import { getOrMakeSearchEditorInput, SearchEditorInput } from 'vs/workbench/contrib/searchEditor/browser/searchEditorInput';
import { serializeSearchResultForEditor } from 'vs/workbench/contrib/searchEditor/browser/searchEditorSerialization';
@ -21,6 +20,8 @@ import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/
import { ISearchConfigurationProperties } from 'vs/workbench/services/search/common/search';
import { searchNewEditorIcon } from 'vs/workbench/contrib/search/browser/searchIcons';
const OpenNewEditorCommandId = 'search.action.openNewEditor';
export const toggleSearchEditorCaseSensitiveCommand = (accessor: ServicesAccessor) => {
const editorService = accessor.get(IEditorService);
const input = editorService.activeEditor;
@ -71,7 +72,7 @@ export const selectAllSearchEditorMatchesCommand = (accessor: ServicesAccessor)
export class OpenSearchEditorAction extends Action {
static readonly ID: string = Constants.OpenNewEditorCommandId;
static readonly ID: string = OpenNewEditorCommandId;
static readonly LABEL = localize('search.openNewEditor', "Open New Search Editor");
constructor(id: string, label: string,