mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-17 03:21:40 -04:00
Merge VS Code 1.31.1 (#4283)
This commit is contained in:
@@ -33,7 +33,7 @@ import { IWorkspaceConfigurationService } from 'vs/workbench/services/configurat
|
||||
import { IJSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditing';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { GroupDirection, IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
|
||||
import { DEFAULT_SETTINGS_EDITOR_SETTING, FOLDER_SETTINGS_PATH, getSettingsTargetName, IPreferencesEditorModel, IPreferencesService, ISetting, ISettingsEditorOptions, SettingsEditorOptions } from 'vs/workbench/services/preferences/common/preferences';
|
||||
import { DEFAULT_SETTINGS_EDITOR_SETTING, FOLDER_SETTINGS_PATH, getSettingsTargetName, IPreferencesEditorModel, IPreferencesService, ISetting, ISettingsEditorOptions, SettingsEditorOptions, USE_SPLIT_JSON_SETTING } from 'vs/workbench/services/preferences/common/preferences';
|
||||
import { DefaultPreferencesEditorInput, KeybindingsEditorInput, PreferencesEditorInput, SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput';
|
||||
import { defaultKeybindingsContents, DefaultKeybindingsEditorModel, DefaultSettings, DefaultSettingsEditorModel, Settings2EditorModel, SettingsEditorModel, WorkspaceConfigurationEditorModel } from 'vs/workbench/services/preferences/common/preferencesModels';
|
||||
|
||||
@@ -45,7 +45,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
|
||||
private lastOpenedSettingsInput: PreferencesEditorInput | null = null;
|
||||
|
||||
private readonly _onDispose: Emitter<void> = new Emitter<void>();
|
||||
private readonly _onDispose = new Emitter<void>();
|
||||
|
||||
private _defaultUserSettingsUriCounter = 0;
|
||||
private _defaultUserSettingsContentModel: DefaultSettings;
|
||||
@@ -55,21 +55,21 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
private _defaultFolderSettingsContentModel: DefaultSettings;
|
||||
|
||||
constructor(
|
||||
@IEditorService private editorService: IEditorService,
|
||||
@IEditorGroupsService private editorGroupService: IEditorGroupsService,
|
||||
@IFileService private fileService: IFileService,
|
||||
@IWorkspaceConfigurationService private configurationService: IWorkspaceConfigurationService,
|
||||
@INotificationService private notificationService: INotificationService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@IEnvironmentService private environmentService: IEnvironmentService,
|
||||
@ITelemetryService private telemetryService: ITelemetryService,
|
||||
@ITextModelService private textModelResolverService: ITextModelService,
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IWorkspaceConfigurationService private readonly configurationService: IWorkspaceConfigurationService,
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@ITelemetryService private readonly telemetryService: ITelemetryService,
|
||||
@ITextModelService private readonly textModelResolverService: ITextModelService,
|
||||
@IKeybindingService keybindingService: IKeybindingService,
|
||||
@IModelService private modelService: IModelService,
|
||||
@IJSONEditingService private jsonEditingService: IJSONEditingService,
|
||||
@IModeService private modeService: IModeService,
|
||||
@ILabelService private labelService: ILabelService
|
||||
@IModelService private readonly modelService: IModelService,
|
||||
@IJSONEditingService private readonly jsonEditingService: IJSONEditingService,
|
||||
@IModeService private readonly modeService: IModeService,
|
||||
@ILabelService private readonly labelService: ILabelService
|
||||
) {
|
||||
super();
|
||||
// The default keybindings.json updates based on keyboard layouts, so here we make sure
|
||||
@@ -103,7 +103,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return this.getEditableSettingsURI(ConfigurationTarget.WORKSPACE_FOLDER, resource);
|
||||
}
|
||||
|
||||
resolveModel(uri: URI): Thenable<ITextModel> {
|
||||
resolveModel(uri: URI): Promise<ITextModel> {
|
||||
if (this.isDefaultSettingsResource(uri)) {
|
||||
|
||||
const target = this.getConfigurationTargetFromDefaultSettingsResource(uri);
|
||||
@@ -150,7 +150,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
createPreferencesEditorModel(uri: URI): Thenable<IPreferencesEditorModel<any>> {
|
||||
createPreferencesEditorModel(uri: URI): Promise<IPreferencesEditorModel<any>> {
|
||||
if (this.isDefaultSettingsResource(uri)) {
|
||||
return this.createDefaultSettingsEditorModel(uri);
|
||||
}
|
||||
@@ -171,15 +171,15 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return Promise.resolve<IPreferencesEditorModel<any>>(null);
|
||||
}
|
||||
|
||||
openRawDefaultSettings(): Thenable<IEditor> {
|
||||
openRawDefaultSettings(): Promise<IEditor> {
|
||||
return this.editorService.openEditor({ resource: this.defaultSettingsRawResource });
|
||||
}
|
||||
|
||||
openRawUserSettings(): Thenable<IEditor> {
|
||||
openRawUserSettings(): Promise<IEditor> {
|
||||
return this.editorService.openEditor({ resource: this.userSettingsResource });
|
||||
}
|
||||
|
||||
openSettings(jsonEditor?: boolean): Thenable<IEditor> {
|
||||
openSettings(jsonEditor?: boolean): Promise<IEditor> {
|
||||
jsonEditor = typeof jsonEditor === 'undefined' ?
|
||||
this.configurationService.getValue('workbench.settings.editor') === 'json' :
|
||||
jsonEditor;
|
||||
@@ -194,13 +194,13 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return this.openOrSwitchSettings(target, resource);
|
||||
}
|
||||
|
||||
private openSettings2(): Thenable<IEditor> {
|
||||
private openSettings2(): Promise<IEditor> {
|
||||
const input = this.settingsEditor2Input;
|
||||
return this.editorGroupService.activeGroup.openEditor(input)
|
||||
.then(() => this.editorGroupService.activeGroup.activeControl);
|
||||
}
|
||||
|
||||
openGlobalSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor> {
|
||||
openGlobalSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor> {
|
||||
jsonEditor = typeof jsonEditor === 'undefined' ?
|
||||
this.configurationService.getValue('workbench.settings.editor') === 'json' :
|
||||
jsonEditor;
|
||||
@@ -210,7 +210,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
this.openOrSwitchSettings2(ConfigurationTarget.USER, undefined, options, group);
|
||||
}
|
||||
|
||||
openWorkspaceSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor> {
|
||||
openWorkspaceSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor | null> {
|
||||
jsonEditor = typeof jsonEditor === 'undefined' ?
|
||||
this.configurationService.getValue('workbench.settings.editor') === 'json' :
|
||||
jsonEditor;
|
||||
@@ -225,7 +225,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
this.openOrSwitchSettings2(ConfigurationTarget.WORKSPACE, undefined, options, group);
|
||||
}
|
||||
|
||||
openFolderSettings(folder: URI, jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor> {
|
||||
openFolderSettings(folder: URI, jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor> {
|
||||
jsonEditor = typeof jsonEditor === 'undefined' ?
|
||||
this.configurationService.getValue('workbench.settings.editor') === 'json' :
|
||||
jsonEditor;
|
||||
@@ -235,7 +235,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
this.openOrSwitchSettings2(ConfigurationTarget.WORKSPACE_FOLDER, folder, options, group);
|
||||
}
|
||||
|
||||
switchSettings(target: ConfigurationTarget, resource: URI, jsonEditor?: boolean): Thenable<void> {
|
||||
switchSettings(target: ConfigurationTarget, resource: URI, jsonEditor?: boolean): Promise<void> {
|
||||
if (!jsonEditor) {
|
||||
return this.doOpenSettings2(target, resource).then(() => null);
|
||||
}
|
||||
@@ -248,7 +248,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
}
|
||||
}
|
||||
|
||||
openGlobalKeybindingSettings(textual: boolean): Thenable<void> {
|
||||
openGlobalKeybindingSettings(textual: boolean): Promise<void> {
|
||||
/* __GDPR__
|
||||
"openKeybindings" : {
|
||||
"textual" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
|
||||
@@ -268,9 +268,9 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return Promise.all([
|
||||
this.editorService.openEditor({ resource: this.defaultKeybindingsResource, options: { pinned: true, preserveFocus: true, revealIfOpened: true }, label: nls.localize('defaultKeybindings', "Default Keybindings"), description: '' }),
|
||||
this.editorService.openEditor({ resource: editableKeybindings, options: { pinned: true, revealIfOpened: true } }, sideEditorGroup.id)
|
||||
]).then(editors => void 0);
|
||||
]).then(editors => undefined);
|
||||
} else {
|
||||
return this.editorService.openEditor({ resource: editableKeybindings, options: { pinned: true, revealIfOpened: true } }).then(() => void 0);
|
||||
return this.editorService.openEditor({ resource: editableKeybindings, options: { pinned: true, revealIfOpened: true } }).then(() => undefined);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -278,7 +278,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return this.editorService.openEditor(this.instantiationService.createInstance(KeybindingsEditorInput), { pinned: true, revealIfOpened: true }).then(() => null);
|
||||
}
|
||||
|
||||
openDefaultKeybindingsFile(): Thenable<IEditor> {
|
||||
openDefaultKeybindingsFile(): Promise<IEditor> {
|
||||
return this.editorService.openEditor({ resource: this.defaultKeybindingsResource, label: nls.localize('defaultKeybindings', "Default Keybindings") });
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
}));
|
||||
}
|
||||
|
||||
private openOrSwitchSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group: IEditorGroup = this.editorGroupService.activeGroup): Thenable<IEditor> {
|
||||
private openOrSwitchSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group: IEditorGroup = this.editorGroupService.activeGroup): Promise<IEditor> {
|
||||
const editorInput = this.getActiveSettingsEditorInput(group);
|
||||
if (editorInput && editorInput.master.getResource().fsPath !== resource.fsPath) {
|
||||
return this.doSwitchSettings(configurationTarget, resource, editorInput, group, options);
|
||||
@@ -308,12 +308,18 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return this.doOpenSettings(configurationTarget, resource, options, group);
|
||||
}
|
||||
|
||||
private openOrSwitchSettings2(configurationTarget: ConfigurationTarget, folderUri?: URI, options?: ISettingsEditorOptions, group: IEditorGroup = this.editorGroupService.activeGroup): Thenable<IEditor> {
|
||||
private openOrSwitchSettings2(configurationTarget: ConfigurationTarget, folderUri?: URI, options?: ISettingsEditorOptions, group: IEditorGroup = this.editorGroupService.activeGroup): Promise<IEditor> {
|
||||
return this.doOpenSettings2(configurationTarget, folderUri, options, group);
|
||||
}
|
||||
|
||||
private doOpenSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor> {
|
||||
private doOpenSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor> {
|
||||
const openSplitJSON = !!this.configurationService.getValue(USE_SPLIT_JSON_SETTING);
|
||||
if (openSplitJSON) {
|
||||
return this.doOpenSplitJSON(configurationTarget, resource, options, group);
|
||||
}
|
||||
|
||||
const openDefaultSettings = !!this.configurationService.getValue(DEFAULT_SETTINGS_EDITOR_SETTING);
|
||||
|
||||
return this.getOrCreateEditableSettingsEditorInput(configurationTarget, resource)
|
||||
.then(editableSettingsEditorInput => {
|
||||
if (!options) {
|
||||
@@ -323,12 +329,31 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
}
|
||||
|
||||
if (openDefaultSettings) {
|
||||
const defaultPreferencesEditorInput = this.instantiationService.createInstance(DefaultPreferencesEditorInput, this.getDefaultSettingsResource(configurationTarget));
|
||||
const preferencesEditorInput = new PreferencesEditorInput(this.getPreferencesEditorInputName(configurationTarget, resource), editableSettingsEditorInput.getDescription(), defaultPreferencesEditorInput, <EditorInput>editableSettingsEditorInput);
|
||||
this.lastOpenedSettingsInput = preferencesEditorInput;
|
||||
return this.editorService.openEditor(preferencesEditorInput, SettingsEditorOptions.create(options), group);
|
||||
const activeEditorGroup = this.editorGroupService.activeGroup;
|
||||
const sideEditorGroup = this.editorGroupService.addGroup(activeEditorGroup.id, GroupDirection.RIGHT);
|
||||
return Promise.all([
|
||||
this.editorService.openEditor({ resource: this.defaultSettingsRawResource, options: { pinned: true, preserveFocus: true, revealIfOpened: true }, label: nls.localize('defaultSettings', "Default Settings"), description: '' }),
|
||||
this.editorService.openEditor(editableSettingsEditorInput, { pinned: true, revealIfOpened: true }, sideEditorGroup.id)
|
||||
]).then(() => null);
|
||||
} else {
|
||||
return this.editorService.openEditor(editableSettingsEditorInput, SettingsEditorOptions.create(options), group);
|
||||
}
|
||||
return this.editorService.openEditor(editableSettingsEditorInput, SettingsEditorOptions.create(options), group);
|
||||
});
|
||||
}
|
||||
|
||||
private doOpenSplitJSON(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor> {
|
||||
return this.getOrCreateEditableSettingsEditorInput(configurationTarget, resource)
|
||||
.then(editableSettingsEditorInput => {
|
||||
if (!options) {
|
||||
options = { pinned: true };
|
||||
} else {
|
||||
options = assign(options, { pinned: true });
|
||||
}
|
||||
|
||||
const defaultPreferencesEditorInput = this.instantiationService.createInstance(DefaultPreferencesEditorInput, this.getDefaultSettingsResource(configurationTarget));
|
||||
const preferencesEditorInput = new PreferencesEditorInput(this.getPreferencesEditorInputName(configurationTarget, resource), editableSettingsEditorInput.getDescription(), defaultPreferencesEditorInput, <EditorInput>editableSettingsEditorInput);
|
||||
this.lastOpenedSettingsInput = preferencesEditorInput;
|
||||
return this.editorService.openEditor(preferencesEditorInput, SettingsEditorOptions.create(options), group);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -336,7 +361,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return this.instantiationService.createInstance(Settings2EditorModel, this.getDefaultSettings(ConfigurationTarget.USER));
|
||||
}
|
||||
|
||||
private doOpenSettings2(target: ConfigurationTarget, folderUri: URI | undefined, options?: IEditorOptions, group?: IEditorGroup): Thenable<IEditor> {
|
||||
private doOpenSettings2(target: ConfigurationTarget, folderUri: URI | undefined, options?: IEditorOptions, group?: IEditorGroup): Promise<IEditor> {
|
||||
const input = this.settingsEditor2Input;
|
||||
const settingsOptions: ISettingsEditorOptions = {
|
||||
...options,
|
||||
@@ -347,7 +372,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return this.editorService.openEditor(input, SettingsEditorOptions.create(settingsOptions), group);
|
||||
}
|
||||
|
||||
private doSwitchSettings(target: ConfigurationTarget, resource: URI, input: PreferencesEditorInput, group: IEditorGroup, options?: ISettingsEditorOptions): Thenable<IEditor> {
|
||||
private doSwitchSettings(target: ConfigurationTarget, resource: URI, input: PreferencesEditorInput, group: IEditorGroup, options?: ISettingsEditorOptions): Promise<IEditor> {
|
||||
return this.getOrCreateEditableSettingsEditorInput(target, this.getEditableSettingsURI(target, resource))
|
||||
.then(toInput => {
|
||||
return group.openEditor(input).then(() => {
|
||||
@@ -422,12 +447,12 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return target === ConfigurationTarget.WORKSPACE_FOLDER ? nls.localize('folderSettingsName', "{0} (Folder Settings)", name) : name;
|
||||
}
|
||||
|
||||
private getOrCreateEditableSettingsEditorInput(target: ConfigurationTarget, resource: URI): Thenable<EditorInput> {
|
||||
private getOrCreateEditableSettingsEditorInput(target: ConfigurationTarget, resource: URI): Promise<EditorInput> {
|
||||
return this.createSettingsIfNotExists(target, resource)
|
||||
.then(() => <EditorInput>this.editorService.createInput({ resource }));
|
||||
}
|
||||
|
||||
private createEditableSettingsEditorModel(configurationTarget: ConfigurationTarget, resource: URI): Thenable<SettingsEditorModel> {
|
||||
private createEditableSettingsEditorModel(configurationTarget: ConfigurationTarget, resource: URI): Promise<SettingsEditorModel> {
|
||||
const settingsUri = this.getEditableSettingsURI(configurationTarget, resource);
|
||||
if (settingsUri) {
|
||||
const workspace = this.contextService.getWorkspace();
|
||||
@@ -441,7 +466,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return Promise.resolve<SettingsEditorModel>(null);
|
||||
}
|
||||
|
||||
private createDefaultSettingsEditorModel(defaultSettingsUri: URI): Thenable<DefaultSettingsEditorModel> {
|
||||
private createDefaultSettingsEditorModel(defaultSettingsUri: URI): Promise<DefaultSettingsEditorModel> {
|
||||
return this.textModelResolverService.createModelReference(defaultSettingsUri)
|
||||
.then(reference => {
|
||||
const target = this.getConfigurationTargetFromDefaultSettingsResource(defaultSettingsUri);
|
||||
@@ -485,17 +510,17 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return null;
|
||||
}
|
||||
|
||||
private createSettingsIfNotExists(target: ConfigurationTarget, resource: URI): Thenable<void> {
|
||||
private createSettingsIfNotExists(target: ConfigurationTarget, resource: URI): Promise<void> {
|
||||
if (this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE && target === ConfigurationTarget.WORKSPACE) {
|
||||
const workspaceConfig = this.contextService.getWorkspace().configuration;
|
||||
if (!workspaceConfig) {
|
||||
return Promise.resolve(null);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
return this.fileService.resolveContent(workspaceConfig)
|
||||
.then(content => {
|
||||
if (Object.keys(parse(content.value)).indexOf('settings') === -1) {
|
||||
return this.jsonEditingService.write(resource, { key: 'settings', value: {} }, true).then(null, () => { });
|
||||
return this.jsonEditingService.write(resource, { key: 'settings', value: {} }, true).then(undefined, () => { });
|
||||
}
|
||||
return null;
|
||||
});
|
||||
@@ -503,10 +528,10 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return this.createIfNotExists(resource, emptyEditableSettingsContent).then(() => { });
|
||||
}
|
||||
|
||||
private createIfNotExists(resource: URI, contents: string): Thenable<any> {
|
||||
return this.fileService.resolveContent(resource, { acceptTextOnly: true }).then(null, error => {
|
||||
private createIfNotExists(resource: URI, contents: string): Promise<any> {
|
||||
return this.fileService.resolveContent(resource, { acceptTextOnly: true }).then(undefined, error => {
|
||||
if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
|
||||
return this.fileService.updateContent(resource, contents).then(null, error => {
|
||||
return this.fileService.updateContent(resource, contents).then(undefined, error => {
|
||||
return Promise.reject(new Error(nls.localize('fail.createSettings', "Unable to create '{0}' ({1}).", this.labelService.getUriLabel(resource, { relative: true }), error)));
|
||||
});
|
||||
}
|
||||
@@ -531,7 +556,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
];
|
||||
}
|
||||
|
||||
private addLanguageOverrideEntry(language: string, settingsModel: IPreferencesEditorModel<ISetting>, codeEditor: ICodeEditor): Thenable<IPosition> {
|
||||
private addLanguageOverrideEntry(language: string, settingsModel: IPreferencesEditorModel<ISetting>, codeEditor: ICodeEditor): Promise<IPosition> {
|
||||
const languageKey = `[${language}]`;
|
||||
let setting = settingsModel.getPreference(languageKey);
|
||||
const model = codeEditor.getModel();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { distinct } from 'vs/base/common/arrays';
|
||||
import { distinct, coalesce } from 'vs/base/common/arrays';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { OperatingSystem, language, LANGUAGE_DEFAULT } from 'vs/base/common/platform';
|
||||
import { IMatch, IFilter, or, matchesContiguousSubString, matchesPrefix, matchesCamelCase, matchesWords } from 'vs/base/common/filters';
|
||||
@@ -19,7 +19,6 @@ import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKe
|
||||
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
|
||||
export const KEYBINDING_ENTRY_TEMPLATE_ID = 'keybinding.entry.template';
|
||||
export const KEYBINDING_HEADER_TEMPLATE_ID = 'keybinding.header.template';
|
||||
|
||||
const SOURCE_DEFAULT = localize('default', "Default");
|
||||
const SOURCE_USER = localize('user', "User");
|
||||
@@ -44,12 +43,12 @@ export interface IListEntry {
|
||||
|
||||
export interface IKeybindingItemEntry extends IListEntry {
|
||||
keybindingItem: IKeybindingItem;
|
||||
commandIdMatches?: IMatch[];
|
||||
commandLabelMatches?: IMatch[];
|
||||
commandDefaultLabelMatches?: IMatch[];
|
||||
sourceMatches?: IMatch[];
|
||||
whenMatches?: IMatch[];
|
||||
keybindingMatches?: KeybindingMatches;
|
||||
commandIdMatches: IMatch[] | null;
|
||||
commandLabelMatches: IMatch[] | null;
|
||||
commandDefaultLabelMatches: IMatch[] | null;
|
||||
sourceMatches: IMatch[] | null;
|
||||
whenMatches: IMatch[] | null;
|
||||
keybindingMatches: KeybindingMatches | null;
|
||||
}
|
||||
|
||||
export interface IKeybindingItem {
|
||||
@@ -78,7 +77,7 @@ export class KeybindingsEditorModel extends EditorModel {
|
||||
|
||||
constructor(
|
||||
os: OperatingSystem,
|
||||
@IKeybindingService private keybindingsService: IKeybindingService
|
||||
@IKeybindingService private readonly keybindingsService: IKeybindingService
|
||||
) {
|
||||
super();
|
||||
this.modifierLabels = {
|
||||
@@ -88,7 +87,7 @@ export class KeybindingsEditorModel extends EditorModel {
|
||||
};
|
||||
}
|
||||
|
||||
public fetch(searchValue: string, sortByPrecedence: boolean = false): IKeybindingItemEntry[] {
|
||||
fetch(searchValue: string, sortByPrecedence: boolean = false): IKeybindingItemEntry[] {
|
||||
let keybindingItems = sortByPrecedence ? this._keybindingItemsSortedByPrecedence : this._keybindingItems;
|
||||
|
||||
if (/@source:\s*(user|default)/i.test(searchValue)) {
|
||||
@@ -98,7 +97,7 @@ export class KeybindingsEditorModel extends EditorModel {
|
||||
|
||||
searchValue = searchValue.trim();
|
||||
if (!searchValue) {
|
||||
return keybindingItems.map(keybindingItem => ({ id: KeybindingsEditorModel.getId(keybindingItem), keybindingItem, templateId: KEYBINDING_ENTRY_TEMPLATE_ID }));
|
||||
return keybindingItems.map(keybindingItem => (<IKeybindingItemEntry>{ id: KeybindingsEditorModel.getId(keybindingItem), keybindingItem, templateId: KEYBINDING_ENTRY_TEMPLATE_ID }));
|
||||
}
|
||||
|
||||
return this.filterByText(keybindingItems, searchValue);
|
||||
@@ -130,7 +129,7 @@ export class KeybindingsEditorModel extends EditorModel {
|
||||
const words = searchValue.split(' ');
|
||||
const keybindingWords = this.splitKeybindingWords(words);
|
||||
for (const keybindingItem of keybindingItems) {
|
||||
let keybindingMatches = new KeybindingItemMatches(this.modifierLabels, keybindingItem, searchValue, words, keybindingWords, completeMatch);
|
||||
const keybindingMatches = new KeybindingItemMatches(this.modifierLabels, keybindingItem, searchValue, words, keybindingWords, completeMatch);
|
||||
if (keybindingMatches.commandIdMatches
|
||||
|| keybindingMatches.commandLabelMatches
|
||||
|| keybindingMatches.commandDefaultLabelMatches
|
||||
@@ -156,12 +155,12 @@ export class KeybindingsEditorModel extends EditorModel {
|
||||
private splitKeybindingWords(wordsSeparatedBySpaces: string[]): string[] {
|
||||
const result: string[] = [];
|
||||
for (const word of wordsSeparatedBySpaces) {
|
||||
result.push(...word.split('+').filter(w => !!w));
|
||||
result.push(...coalesce(word.split('+')));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public resolve(editorActionsLabels: { [id: string]: string; }): Thenable<EditorModel> {
|
||||
resolve(editorActionsLabels: { [id: string]: string; }): Promise<EditorModel> {
|
||||
const workbenchActionsRegistry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
|
||||
|
||||
this._keybindingItemsSortedByPrecedence = [];
|
||||
@@ -224,10 +223,12 @@ export class KeybindingsEditorModel extends EditorModel {
|
||||
};
|
||||
}
|
||||
|
||||
private static getCommandDefaultLabel(menuCommand: ICommandAction, workbenchActionsRegistry: IWorkbenchActionRegistry): string {
|
||||
private static getCommandDefaultLabel(menuCommand: ICommandAction, workbenchActionsRegistry: IWorkbenchActionRegistry): string | null {
|
||||
if (language !== LANGUAGE_DEFAULT) {
|
||||
if (menuCommand && menuCommand.title && (<ILocalizedString>menuCommand.title).original) {
|
||||
return (<ILocalizedString>menuCommand.title).original;
|
||||
const category: string | undefined = menuCommand.category ? (<ILocalizedString>menuCommand.category).original : undefined;
|
||||
const title = (<ILocalizedString>menuCommand.title).original;
|
||||
return category ? localize('cat.title', "{0}: {1}", category, title) : title;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -235,7 +236,9 @@ export class KeybindingsEditorModel extends EditorModel {
|
||||
|
||||
private static getCommandLabel(menuCommand: ICommandAction, editorActionLabel: string): string {
|
||||
if (menuCommand) {
|
||||
return typeof menuCommand.title === 'string' ? menuCommand.title : menuCommand.title.value;
|
||||
const category: string | undefined = menuCommand.category ? typeof menuCommand.category === 'string' ? menuCommand.category : menuCommand.category.value : undefined;
|
||||
const title = typeof menuCommand.title === 'string' ? menuCommand.title : menuCommand.title.value;
|
||||
return category ? localize('cat.title', "{0}: {1}", category, title) : title;
|
||||
}
|
||||
|
||||
if (editorActionLabel) {
|
||||
@@ -248,12 +251,12 @@ export class KeybindingsEditorModel extends EditorModel {
|
||||
|
||||
class KeybindingItemMatches {
|
||||
|
||||
public readonly commandIdMatches: IMatch[] | null = null;
|
||||
public readonly commandLabelMatches: IMatch[] | null = null;
|
||||
public readonly commandDefaultLabelMatches: IMatch[] | null = null;
|
||||
public readonly sourceMatches: IMatch[] | null = null;
|
||||
public readonly whenMatches: IMatch[] | null = null;
|
||||
public readonly keybindingMatches: KeybindingMatches | null = null;
|
||||
readonly commandIdMatches: IMatch[] | null = null;
|
||||
readonly commandLabelMatches: IMatch[] | null = null;
|
||||
readonly commandDefaultLabelMatches: IMatch[] | null = null;
|
||||
readonly sourceMatches: IMatch[] | null = null;
|
||||
readonly whenMatches: IMatch[] | null = null;
|
||||
readonly keybindingMatches: KeybindingMatches | null = null;
|
||||
|
||||
constructor(private modifierLabels: ModifierLabels, keybindingItem: IKeybindingItem, searchValue: string, words: string[], keybindingWords: string[], completeMatch: boolean) {
|
||||
if (!completeMatch) {
|
||||
@@ -266,7 +269,7 @@ class KeybindingItemMatches {
|
||||
this.keybindingMatches = keybindingItem.keybinding ? this.matchesKeybinding(keybindingItem.keybinding, searchValue, keybindingWords, completeMatch) : null;
|
||||
}
|
||||
|
||||
private matches(searchValue: string, wordToMatchAgainst: string, wordMatchesFilter: IFilter, words: string[]): IMatch[] {
|
||||
private matches(searchValue: string, wordToMatchAgainst: string, wordMatchesFilter: IFilter, words: string[]): IMatch[] | null {
|
||||
let matches = wordFilter(searchValue, wordToMatchAgainst);
|
||||
if (!matches) {
|
||||
matches = this.matchesWords(words, wordToMatchAgainst, wordMatchesFilter);
|
||||
@@ -277,8 +280,8 @@ class KeybindingItemMatches {
|
||||
return matches;
|
||||
}
|
||||
|
||||
private matchesWords(words: string[], wordToMatchAgainst: string, wordMatchesFilter: IFilter): IMatch[] {
|
||||
let matches: IMatch[] = [];
|
||||
private matchesWords(words: string[], wordToMatchAgainst: string, wordMatchesFilter: IFilter): IMatch[] | null {
|
||||
let matches: IMatch[] | null = [];
|
||||
for (const word of words) {
|
||||
const wordMatches = wordMatchesFilter(word, wordToMatchAgainst);
|
||||
if (wordMatches) {
|
||||
@@ -295,21 +298,26 @@ class KeybindingItemMatches {
|
||||
return distinct(matches, (a => a.start + '.' + a.end)).filter(match => !matches.some(m => !(m.start === match.start && m.end === match.end) && (m.start <= match.start && m.end >= match.end))).sort((a, b) => a.start - b.start);
|
||||
}
|
||||
|
||||
private matchesKeybinding(keybinding: ResolvedKeybinding, searchValue: string, words: string[], completeMatch: boolean): KeybindingMatches {
|
||||
private matchesKeybinding(keybinding: ResolvedKeybinding, searchValue: string, words: string[], completeMatch: boolean): KeybindingMatches | null {
|
||||
const [firstPart, chordPart] = keybinding.getParts();
|
||||
|
||||
if (strings.compareIgnoreCase(searchValue, keybinding.getUserSettingsLabel()) === 0 || strings.compareIgnoreCase(searchValue, keybinding.getAriaLabel()) === 0 || strings.compareIgnoreCase(searchValue, keybinding.getLabel()) === 0) {
|
||||
const userSettingsLabel = keybinding.getUserSettingsLabel();
|
||||
const ariaLabel = keybinding.getAriaLabel();
|
||||
const label = keybinding.getLabel();
|
||||
if ((userSettingsLabel && strings.compareIgnoreCase(searchValue, userSettingsLabel) === 0)
|
||||
|| (ariaLabel && strings.compareIgnoreCase(searchValue, ariaLabel) === 0)
|
||||
|| (label && strings.compareIgnoreCase(searchValue, label) === 0)) {
|
||||
return {
|
||||
firstPart: this.createCompleteMatch(firstPart),
|
||||
chordPart: this.createCompleteMatch(chordPart)
|
||||
};
|
||||
}
|
||||
|
||||
let firstPartMatch: KeybindingMatch = {};
|
||||
const firstPartMatch: KeybindingMatch = {};
|
||||
let chordPartMatch: KeybindingMatch = {};
|
||||
|
||||
const matchedWords: number[] = [];
|
||||
let firstPartMatchedWords: number[] = [];
|
||||
const firstPartMatchedWords: number[] = [];
|
||||
let chordPartMatchedWords: number[] = [];
|
||||
let matchFirstPart = true;
|
||||
for (let index = 0; index < words.length; index++) {
|
||||
@@ -359,7 +367,7 @@ class KeybindingItemMatches {
|
||||
return this.hasAnyMatch(firstPartMatch) || this.hasAnyMatch(chordPartMatch) ? { firstPart: firstPartMatch, chordPart: chordPartMatch } : null;
|
||||
}
|
||||
|
||||
private matchPart(part: ResolvedKeybindingPart, match: KeybindingMatch, word: string, completeMatch: boolean): boolean {
|
||||
private matchPart(part: ResolvedKeybindingPart | null, match: KeybindingMatch, word: string, completeMatch: boolean): boolean {
|
||||
let matched = false;
|
||||
if (this.matchesMetaModifier(part, word)) {
|
||||
matched = true;
|
||||
@@ -384,11 +392,11 @@ class KeybindingItemMatches {
|
||||
return matched;
|
||||
}
|
||||
|
||||
private matchesKeyCode(keybinding: ResolvedKeybindingPart, word: string, completeMatch: boolean): boolean {
|
||||
private matchesKeyCode(keybinding: ResolvedKeybindingPart | null, word: string, completeMatch: boolean): boolean {
|
||||
if (!keybinding) {
|
||||
return false;
|
||||
}
|
||||
const ariaLabel = keybinding.keyAriaLabel;
|
||||
const ariaLabel: string = keybinding.keyAriaLabel || '';
|
||||
if (completeMatch || ariaLabel.length === 1 || word.length === 1) {
|
||||
if (strings.compareIgnoreCase(ariaLabel, word) === 0) {
|
||||
return true;
|
||||
@@ -401,7 +409,7 @@ class KeybindingItemMatches {
|
||||
return false;
|
||||
}
|
||||
|
||||
private matchesMetaModifier(keybinding: ResolvedKeybindingPart, word: string): boolean {
|
||||
private matchesMetaModifier(keybinding: ResolvedKeybindingPart | null, word: string): boolean {
|
||||
if (!keybinding) {
|
||||
return false;
|
||||
}
|
||||
@@ -427,7 +435,7 @@ class KeybindingItemMatches {
|
||||
return false;
|
||||
}
|
||||
|
||||
private matchesCtrlModifier(keybinding: ResolvedKeybindingPart, word: string): boolean {
|
||||
private matchesCtrlModifier(keybinding: ResolvedKeybindingPart | null, word: string): boolean {
|
||||
if (!keybinding) {
|
||||
return false;
|
||||
}
|
||||
@@ -450,7 +458,7 @@ class KeybindingItemMatches {
|
||||
return false;
|
||||
}
|
||||
|
||||
private matchesShiftModifier(keybinding: ResolvedKeybindingPart, word: string): boolean {
|
||||
private matchesShiftModifier(keybinding: ResolvedKeybindingPart | null, word: string): boolean {
|
||||
if (!keybinding) {
|
||||
return false;
|
||||
}
|
||||
@@ -473,7 +481,7 @@ class KeybindingItemMatches {
|
||||
return false;
|
||||
}
|
||||
|
||||
private matchesAltModifier(keybinding: ResolvedKeybindingPart, word: string): boolean {
|
||||
private matchesAltModifier(keybinding: ResolvedKeybindingPart | null, word: string): boolean {
|
||||
if (!keybinding) {
|
||||
return false;
|
||||
}
|
||||
@@ -500,14 +508,14 @@ class KeybindingItemMatches {
|
||||
}
|
||||
|
||||
private hasAnyMatch(keybindingMatch: KeybindingMatch): boolean {
|
||||
return keybindingMatch.altKey ||
|
||||
keybindingMatch.ctrlKey ||
|
||||
keybindingMatch.metaKey ||
|
||||
keybindingMatch.shiftKey ||
|
||||
keybindingMatch.keyCode;
|
||||
return !!keybindingMatch.altKey ||
|
||||
!!keybindingMatch.ctrlKey ||
|
||||
!!keybindingMatch.metaKey ||
|
||||
!!keybindingMatch.shiftKey ||
|
||||
!!keybindingMatch.keyCode;
|
||||
}
|
||||
|
||||
private isCompleteMatch(part: ResolvedKeybindingPart, match: KeybindingMatch): boolean {
|
||||
private isCompleteMatch(part: ResolvedKeybindingPart | null, match: KeybindingMatch): boolean {
|
||||
if (!part) {
|
||||
return true;
|
||||
}
|
||||
@@ -529,8 +537,8 @@ class KeybindingItemMatches {
|
||||
return true;
|
||||
}
|
||||
|
||||
private createCompleteMatch(part: ResolvedKeybindingPart): KeybindingMatch {
|
||||
let match: KeybindingMatch = {};
|
||||
private createCompleteMatch(part: ResolvedKeybindingPart | null): KeybindingMatch {
|
||||
const match: KeybindingMatch = {};
|
||||
if (part) {
|
||||
match.keyCode = true;
|
||||
if (part.metaKey) {
|
||||
|
||||
@@ -201,18 +201,18 @@ export interface IPreferencesService {
|
||||
workspaceSettingsResource: URI;
|
||||
getFolderSettingsResource(resource: URI): URI;
|
||||
|
||||
resolveModel(uri: URI): Thenable<ITextModel>;
|
||||
createPreferencesEditorModel<T>(uri: URI): Thenable<IPreferencesEditorModel<T>>;
|
||||
resolveModel(uri: URI): Promise<ITextModel>;
|
||||
createPreferencesEditorModel<T>(uri: URI): Promise<IPreferencesEditorModel<T>>;
|
||||
createSettings2EditorModel(): Settings2EditorModel; // TODO
|
||||
|
||||
openRawDefaultSettings(): Thenable<IEditor>;
|
||||
openSettings(jsonEditor?: boolean): Thenable<IEditor>;
|
||||
openGlobalSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor>;
|
||||
openWorkspaceSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor>;
|
||||
openFolderSettings(folder: URI, jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor>;
|
||||
switchSettings(target: ConfigurationTarget, resource: URI, jsonEditor?: boolean): Thenable<void>;
|
||||
openGlobalKeybindingSettings(textual: boolean): Thenable<void>;
|
||||
openDefaultKeybindingsFile(): Thenable<IEditor>;
|
||||
openRawDefaultSettings(): Promise<IEditor>;
|
||||
openSettings(jsonEditor?: boolean): Promise<IEditor>;
|
||||
openGlobalSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor>;
|
||||
openWorkspaceSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor>;
|
||||
openFolderSettings(folder: URI, jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor>;
|
||||
switchSettings(target: ConfigurationTarget, resource: URI, jsonEditor?: boolean): Promise<void>;
|
||||
openGlobalKeybindingSettings(textual: boolean): Promise<void>;
|
||||
openDefaultKeybindingsFile(): Promise<IEditor>;
|
||||
|
||||
configureSettingsForLanguage(language: string): void;
|
||||
}
|
||||
@@ -232,3 +232,4 @@ export function getSettingsTargetName(target: ConfigurationTarget, resource: URI
|
||||
|
||||
export const FOLDER_SETTINGS_PATH = join('.vscode', 'settings.json');
|
||||
export const DEFAULT_SETTINGS_EDITOR_SETTING = 'workbench.settings.openDefaultSettings';
|
||||
export const USE_SPLIT_JSON_SETTING = 'workbench.settings.useSplitJSON';
|
||||
|
||||
@@ -16,19 +16,19 @@ import { IPreferencesService } from 'vs/workbench/services/preferences/common/pr
|
||||
import { Settings2EditorModel } from 'vs/workbench/services/preferences/common/preferencesModels';
|
||||
|
||||
export class PreferencesEditorInput extends SideBySideEditorInput {
|
||||
public static readonly ID: string = 'workbench.editorinputs.preferencesEditorInput';
|
||||
static readonly ID: string = 'workbench.editorinputs.preferencesEditorInput';
|
||||
|
||||
getTypeId(): string {
|
||||
return PreferencesEditorInput.ID;
|
||||
}
|
||||
|
||||
public getTitle(verbosity: Verbosity): string {
|
||||
getTitle(verbosity: Verbosity): string {
|
||||
return this.master.getTitle(verbosity);
|
||||
}
|
||||
}
|
||||
|
||||
export class DefaultPreferencesEditorInput extends ResourceEditorInput {
|
||||
public static readonly ID = 'workbench.editorinputs.defaultpreferences';
|
||||
static readonly ID = 'workbench.editorinputs.defaultpreferences';
|
||||
constructor(defaultSettingsResource: URI,
|
||||
@ITextModelService textModelResolverService: ITextModelService,
|
||||
@IHashService hashService: IHashService
|
||||
@@ -53,8 +53,8 @@ export class DefaultPreferencesEditorInput extends ResourceEditorInput {
|
||||
|
||||
export class KeybindingsEditorInput extends EditorInput {
|
||||
|
||||
public static readonly ID: string = 'workbench.input.keybindings';
|
||||
public readonly keybindingsModel: KeybindingsEditorModel;
|
||||
static readonly ID: string = 'workbench.input.keybindings';
|
||||
readonly keybindingsModel: KeybindingsEditorModel;
|
||||
|
||||
constructor(@IInstantiationService instantiationService: IInstantiationService) {
|
||||
super();
|
||||
@@ -69,7 +69,7 @@ export class KeybindingsEditorInput extends EditorInput {
|
||||
return nls.localize('keybindingsInputName', "Keyboard Shortcuts");
|
||||
}
|
||||
|
||||
resolve(): Thenable<KeybindingsEditorModel> {
|
||||
resolve(): Promise<KeybindingsEditorModel> {
|
||||
return Promise.resolve(this.keybindingsModel);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ export class KeybindingsEditorInput extends EditorInput {
|
||||
|
||||
export class SettingsEditor2Input extends EditorInput {
|
||||
|
||||
public static readonly ID: string = 'workbench.input.settings2';
|
||||
static readonly ID: string = 'workbench.input.settings2';
|
||||
private readonly _settingsModel: Settings2EditorModel;
|
||||
private resource: URI = URI.from({
|
||||
scheme: 'vscode-settings',
|
||||
@@ -107,11 +107,11 @@ export class SettingsEditor2Input extends EditorInput {
|
||||
return nls.localize('settingsEditor2InputName', "Settings");
|
||||
}
|
||||
|
||||
resolve(): Thenable<Settings2EditorModel> {
|
||||
resolve(): Promise<Settings2EditorModel> {
|
||||
return Promise.resolve(this._settingsModel);
|
||||
}
|
||||
|
||||
public getResource(): URI {
|
||||
getResource(): URI {
|
||||
return this.resource;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { flatten, tail, find } from 'vs/base/common/arrays';
|
||||
import { flatten, tail, find, coalesce } from 'vs/base/common/arrays';
|
||||
import { IStringDictionary } from 'vs/base/common/collections';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { JSONVisitor, visit } from 'vs/base/common/json';
|
||||
@@ -27,7 +27,7 @@ export abstract class AbstractSettingsModel extends EditorModel {
|
||||
|
||||
protected _currentResultGroups = new Map<string, ISearchResultGroup>();
|
||||
|
||||
public updateResultGroup(id: string, resultGroup: ISearchResultGroup): IFilterResult {
|
||||
updateResultGroup(id: string, resultGroup: ISearchResultGroup): IFilterResult {
|
||||
if (resultGroup) {
|
||||
this._currentResultGroups.set(id, resultGroup);
|
||||
} else {
|
||||
@@ -52,7 +52,7 @@ export abstract class AbstractSettingsModel extends EditorModel {
|
||||
});
|
||||
}
|
||||
|
||||
public filterSettings(filter: string, groupFilter: IGroupFilter, settingMatcher: ISettingMatcher): ISettingMatch[] {
|
||||
filterSettings(filter: string, groupFilter: IGroupFilter, settingMatcher: ISettingMatcher): ISettingMatch[] {
|
||||
const allGroups = this.filterGroups;
|
||||
|
||||
const filterMatches: ISettingMatch[] = [];
|
||||
@@ -76,7 +76,7 @@ export abstract class AbstractSettingsModel extends EditorModel {
|
||||
return filterMatches.sort((a, b) => b.score - a.score);
|
||||
}
|
||||
|
||||
public getPreference(key: string): ISetting {
|
||||
getPreference(key: string): ISetting {
|
||||
for (const group of this.settingsGroups) {
|
||||
for (const section of group.sections) {
|
||||
for (const setting of section.settings) {
|
||||
@@ -107,9 +107,9 @@ export abstract class AbstractSettingsModel extends EditorModel {
|
||||
return this.settingsGroups;
|
||||
}
|
||||
|
||||
public abstract settingsGroups: ISettingsGroup[];
|
||||
abstract settingsGroups: ISettingsGroup[];
|
||||
|
||||
public abstract findValueMatches(filter: string, setting: ISetting): IRange[];
|
||||
abstract findValueMatches(filter: string, setting: ISetting): IRange[];
|
||||
|
||||
protected abstract update(): IFilterResult;
|
||||
}
|
||||
@@ -132,26 +132,26 @@ export class SettingsEditorModel extends AbstractSettingsModel implements ISetti
|
||||
}));
|
||||
}
|
||||
|
||||
public get uri(): URI {
|
||||
get uri(): URI {
|
||||
return this.settingsModel.uri;
|
||||
}
|
||||
|
||||
public get configurationTarget(): ConfigurationTarget {
|
||||
get configurationTarget(): ConfigurationTarget {
|
||||
return this._configurationTarget;
|
||||
}
|
||||
|
||||
public get settingsGroups(): ISettingsGroup[] {
|
||||
get settingsGroups(): ISettingsGroup[] {
|
||||
if (!this._settingsGroups) {
|
||||
this.parse();
|
||||
}
|
||||
return this._settingsGroups;
|
||||
}
|
||||
|
||||
public get content(): string {
|
||||
get content(): string {
|
||||
return this.settingsModel.getValue();
|
||||
}
|
||||
|
||||
public findValueMatches(filter: string, setting: ISetting): IRange[] {
|
||||
findValueMatches(filter: string, setting: ISetting): IRange[] {
|
||||
return this.settingsModel.findMatches(filter, setting.valueRange, false, false, null, false).map(match => match.range);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ export class SettingsEditorModel extends AbstractSettingsModel implements ISetti
|
||||
}
|
||||
|
||||
const metadata = this.collectMetadata(resultGroups);
|
||||
return <IFilterResult>{
|
||||
return {
|
||||
allGroups: this.settingsGroups,
|
||||
filteredGroups: filteredGroup ? [filteredGroup] : [],
|
||||
matches,
|
||||
@@ -229,13 +229,13 @@ export class Settings2EditorModel extends AbstractSettingsModel implements ISett
|
||||
return this.settingsGroups.slice(1);
|
||||
}
|
||||
|
||||
public get settingsGroups(): ISettingsGroup[] {
|
||||
get settingsGroups(): ISettingsGroup[] {
|
||||
const groups = this._defaultSettings.getSettingsGroups(this.dirty);
|
||||
this.dirty = false;
|
||||
return groups;
|
||||
}
|
||||
|
||||
public findValueMatches(filter: string, setting: ISetting): IRange[] {
|
||||
findValueMatches(filter: string, setting: ISetting): IRange[] {
|
||||
// TODO @roblou
|
||||
return [];
|
||||
}
|
||||
@@ -251,9 +251,9 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
|
||||
let currentProperty: string | null = null;
|
||||
let currentParent: any = [];
|
||||
let previousParents: any[] = [];
|
||||
const previousParents: any[] = [];
|
||||
let settingsPropertyIndex: number = -1;
|
||||
let range = {
|
||||
const range = {
|
||||
startLineNumber: 0,
|
||||
startColumn: 0,
|
||||
endLineNumber: 0,
|
||||
@@ -270,8 +270,8 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
// settings value started
|
||||
const setting = previousParents.length === settingsPropertyIndex + 1 ? settings[settings.length - 1] : overrideSetting.overrides[overrideSetting.overrides.length - 1];
|
||||
if (setting) {
|
||||
let valueStartPosition = model.getPositionAt(offset);
|
||||
let valueEndPosition = model.getPositionAt(offset + length);
|
||||
const valueStartPosition = model.getPositionAt(offset);
|
||||
const valueEndPosition = model.getPositionAt(offset + length);
|
||||
setting.value = value;
|
||||
setting.valueRange = {
|
||||
startLineNumber: valueStartPosition.lineNumber,
|
||||
@@ -286,16 +286,16 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
}
|
||||
}
|
||||
}
|
||||
let visitor: JSONVisitor = {
|
||||
const visitor: JSONVisitor = {
|
||||
onObjectBegin: (offset: number, length: number) => {
|
||||
if (isSettingsProperty(currentProperty, previousParents)) {
|
||||
// Settings started
|
||||
settingsPropertyIndex = previousParents.length;
|
||||
let position = model.getPositionAt(offset);
|
||||
const position = model.getPositionAt(offset);
|
||||
range.startLineNumber = position.lineNumber;
|
||||
range.startColumn = position.column;
|
||||
}
|
||||
let object = {};
|
||||
const object = {};
|
||||
onValue(object, offset, length);
|
||||
currentParent = object;
|
||||
currentProperty = null;
|
||||
@@ -305,7 +305,7 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
currentProperty = name;
|
||||
if (previousParents.length === settingsPropertyIndex + 1 || (previousParents.length === settingsPropertyIndex + 2 && overrideSetting !== null)) {
|
||||
// setting started
|
||||
let settingStartPosition = model.getPositionAt(offset);
|
||||
const settingStartPosition = model.getPositionAt(offset);
|
||||
const setting: ISetting = {
|
||||
description: [],
|
||||
descriptionIsMarkdown: false,
|
||||
@@ -344,7 +344,7 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
// setting ended
|
||||
const setting = previousParents.length === settingsPropertyIndex + 1 ? settings[settings.length - 1] : overrideSetting.overrides[overrideSetting.overrides.length - 1];
|
||||
if (setting) {
|
||||
let valueEndPosition = model.getPositionAt(offset + length);
|
||||
const valueEndPosition = model.getPositionAt(offset + length);
|
||||
setting.valueRange = assign(setting.valueRange, {
|
||||
endLineNumber: valueEndPosition.lineNumber,
|
||||
endColumn: valueEndPosition.column
|
||||
@@ -361,13 +361,13 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
}
|
||||
if (previousParents.length === settingsPropertyIndex) {
|
||||
// settings ended
|
||||
let position = model.getPositionAt(offset);
|
||||
const position = model.getPositionAt(offset);
|
||||
range.endLineNumber = position.lineNumber;
|
||||
range.endColumn = position.column;
|
||||
}
|
||||
},
|
||||
onArrayBegin: (offset: number, length: number) => {
|
||||
let array: any[] = [];
|
||||
const array: any[] = [];
|
||||
onValue(array, offset, length);
|
||||
previousParents.push(currentParent);
|
||||
currentParent = array;
|
||||
@@ -379,7 +379,7 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
// setting value ended
|
||||
const setting = previousParents.length === settingsPropertyIndex + 1 ? settings[settings.length - 1] : overrideSetting.overrides[overrideSetting.overrides.length - 1];
|
||||
if (setting) {
|
||||
let valueEndPosition = model.getPositionAt(offset + length);
|
||||
const valueEndPosition = model.getPositionAt(offset + length);
|
||||
setting.valueRange = assign(setting.valueRange, {
|
||||
endLineNumber: valueEndPosition.lineNumber,
|
||||
endColumn: valueEndPosition.column
|
||||
@@ -453,7 +453,7 @@ export class DefaultSettings extends Disposable {
|
||||
|
||||
getContent(forceUpdate = false): string {
|
||||
if (!this._content || forceUpdate) {
|
||||
this._content = this.toContent(true, this.getSettingsGroups(forceUpdate));
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
return this._content;
|
||||
@@ -461,12 +461,17 @@ export class DefaultSettings extends Disposable {
|
||||
|
||||
getSettingsGroups(forceUpdate = false): ISettingsGroup[] {
|
||||
if (!this._allSettingsGroups || forceUpdate) {
|
||||
this._allSettingsGroups = this.parse();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
return this._allSettingsGroups;
|
||||
}
|
||||
|
||||
private initialize(): void {
|
||||
this._allSettingsGroups = this.parse();
|
||||
this._content = this.toContent(this._allSettingsGroups);
|
||||
}
|
||||
|
||||
private parse(): ISettingsGroup[] {
|
||||
const settingsGroups = this.getRegisteredGroups();
|
||||
this.initAllSettingsMap(settingsGroups);
|
||||
@@ -476,7 +481,7 @@ export class DefaultSettings extends Disposable {
|
||||
|
||||
get raw(): string {
|
||||
if (!DefaultSettings._RAW) {
|
||||
DefaultSettings._RAW = this.toContent(false, this.getRegisteredGroups());
|
||||
DefaultSettings._RAW = this.toContent(this.getRegisteredGroups());
|
||||
}
|
||||
|
||||
return DefaultSettings._RAW;
|
||||
@@ -512,7 +517,7 @@ export class DefaultSettings extends Disposable {
|
||||
}
|
||||
|
||||
private getMostCommonlyUsedSettings(allSettingsGroups: ISettingsGroup[]): ISettingsGroup {
|
||||
const settings = this._mostCommonlyUsedSettingsKeys.map(key => {
|
||||
const settings = coalesce(this._mostCommonlyUsedSettingsKeys.map(key => {
|
||||
const setting = this._settingsByName.get(key);
|
||||
if (setting) {
|
||||
return <ISetting>{
|
||||
@@ -529,7 +534,7 @@ export class DefaultSettings extends Disposable {
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}).filter(setting => !!setting);
|
||||
}));
|
||||
|
||||
return <ISettingsGroup>{
|
||||
id: 'mostCommonlyUsed',
|
||||
@@ -598,8 +603,8 @@ export class DefaultSettings extends Disposable {
|
||||
}
|
||||
|
||||
private parseSettings(settingsObject: { [path: string]: IConfigurationPropertySchema; }): ISetting[] {
|
||||
let result: ISetting[] = [];
|
||||
for (let key in settingsObject) {
|
||||
const result: ISetting[] = [];
|
||||
for (const key in settingsObject) {
|
||||
const prop = settingsObject[key];
|
||||
if (this.matchesScope(prop)) {
|
||||
const value = prop.default;
|
||||
@@ -668,18 +673,14 @@ export class DefaultSettings extends Disposable {
|
||||
return c1.order - c2.order;
|
||||
}
|
||||
|
||||
private toContent(asArray: boolean, settingsGroups: ISettingsGroup[]): string {
|
||||
private toContent(settingsGroups: ISettingsGroup[]): string {
|
||||
const builder = new SettingsContentBuilder();
|
||||
if (asArray) {
|
||||
builder.pushLine('[');
|
||||
}
|
||||
builder.pushLine('[');
|
||||
settingsGroups.forEach((settingsGroup, i) => {
|
||||
builder.pushGroup(settingsGroup);
|
||||
builder.pushLine(',');
|
||||
});
|
||||
if (asArray) {
|
||||
builder.pushLine(']');
|
||||
}
|
||||
builder.pushLine(']');
|
||||
return builder.getContent();
|
||||
}
|
||||
|
||||
@@ -704,15 +705,15 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
|
||||
this._register(this.onDispose(() => reference.dispose()));
|
||||
}
|
||||
|
||||
public get uri(): URI {
|
||||
get uri(): URI {
|
||||
return this._uri;
|
||||
}
|
||||
|
||||
public get target(): ConfigurationTarget {
|
||||
get target(): ConfigurationTarget {
|
||||
return this.defaultSettings.target;
|
||||
}
|
||||
|
||||
public get settingsGroups(): ISettingsGroup[] {
|
||||
get settingsGroups(): ISettingsGroup[] {
|
||||
return this.defaultSettings.getSettingsGroups();
|
||||
}
|
||||
|
||||
@@ -841,11 +842,11 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
|
||||
};
|
||||
}
|
||||
|
||||
public findValueMatches(filter: string, setting: ISetting): IRange[] {
|
||||
findValueMatches(filter: string, setting: ISetting): IRange[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
public getPreference(key: string): ISetting {
|
||||
getPreference(key: string): ISetting {
|
||||
for (const group of this.settingsGroups) {
|
||||
for (const section of group.sections) {
|
||||
for (const setting of section.settings) {
|
||||
@@ -915,10 +916,10 @@ class SettingsContentBuilder {
|
||||
private _pushGroup(group: ISettingsGroup): ISetting {
|
||||
const indent = ' ';
|
||||
let lastSetting: ISetting | null = null;
|
||||
let groupStart = this.lineCountWithOffset + 1;
|
||||
const groupStart = this.lineCountWithOffset + 1;
|
||||
for (const section of group.sections) {
|
||||
if (section.title) {
|
||||
let sectionTitleStart = this.lineCountWithOffset + 1;
|
||||
const sectionTitleStart = this.lineCountWithOffset + 1;
|
||||
this.addDescription([section.title], indent, this._contentByLines);
|
||||
section.titleRange = { startLineNumber: sectionTitleStart, startColumn: 1, endLineNumber: this.lineCountWithOffset, endColumn: this.lastLine.length };
|
||||
}
|
||||
@@ -986,7 +987,7 @@ class SettingsContentBuilder {
|
||||
}
|
||||
|
||||
private pushValue(setting: ISetting, preValueConent: string, indent: string): void {
|
||||
let valueString = JSON.stringify(setting.value, null, indent);
|
||||
const valueString = JSON.stringify(setting.value, null, indent);
|
||||
if (valueString && (typeof setting.value === 'object')) {
|
||||
if (setting.overrides.length) {
|
||||
this._contentByLines.push(preValueConent + ' {');
|
||||
@@ -1048,7 +1049,7 @@ export function createValidator(prop: IConfigurationPropertySchema): ((value: an
|
||||
|
||||
type Validator<T> = { enabled: boolean, isValid: (value: T) => boolean; message: string };
|
||||
|
||||
let numericValidations: Validator<number>[] = isNumeric ? [
|
||||
const numericValidations: Validator<number>[] = isNumeric ? [
|
||||
{
|
||||
enabled: exclusiveMax !== undefined && (prop.maximum === undefined || exclusiveMax <= prop.maximum),
|
||||
isValid: (value => value < exclusiveMax),
|
||||
@@ -1082,7 +1083,7 @@ export function createValidator(prop: IConfigurationPropertySchema): ((value: an
|
||||
},
|
||||
].filter(validation => validation.enabled) : [];
|
||||
|
||||
let stringValidations: Validator<string>[] = [
|
||||
const stringValidations: Validator<string>[] = [
|
||||
{
|
||||
enabled: prop.maxLength !== undefined,
|
||||
isValid: (value => value.length <= prop.maxLength),
|
||||
@@ -1103,7 +1104,7 @@ export function createValidator(prop: IConfigurationPropertySchema): ((value: an
|
||||
if (prop.type === 'string' && stringValidations.length === 0) { return null; }
|
||||
if (isNullable && value === '') { return ''; }
|
||||
|
||||
let errors: string[] = [];
|
||||
const errors: string[] = [];
|
||||
|
||||
if (isNumeric) {
|
||||
if (value === '' || isNaN(+value)) {
|
||||
@@ -1139,25 +1140,25 @@ export class DefaultKeybindingsEditorModel implements IKeybindingsEditorModel<an
|
||||
private _content: string;
|
||||
|
||||
constructor(private _uri: URI,
|
||||
@IKeybindingService private keybindingService: IKeybindingService) {
|
||||
@IKeybindingService private readonly keybindingService: IKeybindingService) {
|
||||
}
|
||||
|
||||
public get uri(): URI {
|
||||
get uri(): URI {
|
||||
return this._uri;
|
||||
}
|
||||
|
||||
public get content(): string {
|
||||
get content(): string {
|
||||
if (!this._content) {
|
||||
this._content = defaultKeybindingsContents(this.keybindingService);
|
||||
}
|
||||
return this._content;
|
||||
}
|
||||
|
||||
public getPreference(): any {
|
||||
getPreference(): any {
|
||||
return null;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
dispose(): void {
|
||||
// Not disposable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as uuid from 'vs/base/common/uuid';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { OS, OperatingSystem } from 'vs/base/common/platform';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
@@ -44,7 +43,7 @@ suite('KeybindingsEditorModel test', () => {
|
||||
instantiationService = new TestInstantiationService();
|
||||
|
||||
instantiationService.stub(IKeybindingService, {});
|
||||
instantiationService.stub(IExtensionService, {}, 'whenInstalledExtensionsRegistered', () => TPromise.as(null));
|
||||
instantiationService.stub(IExtensionService, {}, 'whenInstalledExtensionsRegistered', () => Promise.resolve(null));
|
||||
|
||||
testObject = instantiationService.createInstance(KeybindingsEditorModel, OS);
|
||||
|
||||
@@ -107,8 +106,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
aResolvedKeybindingItem({ command: 'd' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, chordPart: { keyCode: KeyCode.Escape } })
|
||||
);
|
||||
|
||||
registerCommandWithTitle(keybindings[1].command, 'B Title');
|
||||
registerCommandWithTitle(keybindings[3].command, 'A Title');
|
||||
registerCommandWithTitle(keybindings[1].command!, 'B Title');
|
||||
registerCommandWithTitle(keybindings[3].command!, 'A Title');
|
||||
|
||||
const expected = [keybindings[3], keybindings[1], keybindings[0], keybindings[2]];
|
||||
instantiationService.stub(IKeybindingService, 'getKeybindings', () => keybindings);
|
||||
@@ -128,8 +127,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
aResolvedKeybindingItem({ command: sameId, firstPart: { keyCode: KeyCode.Escape }, isDefault: false })
|
||||
);
|
||||
|
||||
registerCommandWithTitle(keybindings[1].command, 'Same Title');
|
||||
registerCommandWithTitle(keybindings[3].command, 'Same Title');
|
||||
registerCommandWithTitle(keybindings[1].command!, 'Same Title');
|
||||
registerCommandWithTitle(keybindings[3].command!, 'Same Title');
|
||||
const expected = [keybindings[3], keybindings[1], keybindings[0], keybindings[2]];
|
||||
|
||||
await testObject.resolve({});
|
||||
@@ -158,22 +157,22 @@ suite('KeybindingsEditorModel test', () => {
|
||||
assert.equal(actual.keybindingItem.command, expected.command);
|
||||
assert.equal(actual.keybindingItem.commandLabel, '');
|
||||
assert.equal(actual.keybindingItem.commandDefaultLabel, null);
|
||||
assert.equal(actual.keybindingItem.keybinding.getAriaLabel(), expected.resolvedKeybinding.getAriaLabel());
|
||||
assert.equal(actual.keybindingItem.when, expected.when.serialize());
|
||||
assert.equal(actual.keybindingItem.keybinding.getAriaLabel(), expected.resolvedKeybinding!.getAriaLabel());
|
||||
assert.equal(actual.keybindingItem.when, expected.when!.serialize());
|
||||
});
|
||||
|
||||
test('convert keybinding with title to entry', async () => {
|
||||
const expected = aResolvedKeybindingItem({ command: 'a' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, when: 'context1 && context2' });
|
||||
prepareKeybindingService(expected);
|
||||
registerCommandWithTitle(expected.command, 'Some Title');
|
||||
registerCommandWithTitle(expected.command!, 'Some Title');
|
||||
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('')[0];
|
||||
assert.equal(actual.keybindingItem.command, expected.command);
|
||||
assert.equal(actual.keybindingItem.commandLabel, 'Some Title');
|
||||
assert.equal(actual.keybindingItem.commandDefaultLabel, null);
|
||||
assert.equal(actual.keybindingItem.keybinding.getAriaLabel(), expected.resolvedKeybinding.getAriaLabel());
|
||||
assert.equal(actual.keybindingItem.when, expected.when.serialize());
|
||||
assert.equal(actual.keybindingItem.keybinding.getAriaLabel(), expected.resolvedKeybinding!.getAriaLabel());
|
||||
assert.equal(actual.keybindingItem.when, expected.when!.serialize());
|
||||
});
|
||||
|
||||
test('convert without title and binding to entry', async () => {
|
||||
@@ -283,8 +282,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('cmd').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter by meta key', async () => {
|
||||
@@ -297,8 +296,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('meta').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter by command key', async () => {
|
||||
@@ -311,8 +310,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('command').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter by windows key', async () => {
|
||||
@@ -325,8 +324,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('windows').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter by alt key', async () => {
|
||||
@@ -337,8 +336,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('alt').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { altKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter by option key', async () => {
|
||||
@@ -349,8 +348,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('option').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { altKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter by ctrl key', async () => {
|
||||
@@ -361,8 +360,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('ctrl').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { ctrlKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter by control key', async () => {
|
||||
@@ -373,8 +372,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('control').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { ctrlKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter by shift key', async () => {
|
||||
@@ -385,8 +384,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('shift').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { shiftKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter by arrow', async () => {
|
||||
@@ -397,8 +396,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('arrow').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter by modifier and key', async () => {
|
||||
@@ -409,8 +408,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('alt right').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { altKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter by key and modifier', async () => {
|
||||
@@ -432,8 +431,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('alt cmd esc').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true, metaKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { altKey: true, metaKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter by modifiers in random order and key', async () => {
|
||||
@@ -445,8 +444,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('cmd shift esc').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true, shiftKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true, shiftKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter by first part', async () => {
|
||||
@@ -458,8 +457,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('cmd shift esc').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true, shiftKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true, shiftKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter matches in chord part', async () => {
|
||||
@@ -471,8 +470,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('cmd del').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, { keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, { keyCode: true });
|
||||
});
|
||||
|
||||
test('filter matches first part and in chord part', async () => {
|
||||
@@ -484,8 +483,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('cmd shift esc del').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, { keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { shiftKey: true, metaKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, { keyCode: true });
|
||||
});
|
||||
|
||||
test('filter exact matches', async () => {
|
||||
@@ -496,8 +495,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('"ctrl c"').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { ctrlKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter exact matches with first and chord part', async () => {
|
||||
@@ -508,8 +507,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('"shift meta escape ctrl c"').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, { ctrlKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { shiftKey: true, metaKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, { ctrlKey: true, keyCode: true });
|
||||
});
|
||||
|
||||
test('filter exact matches with first and chord part no results', async () => {
|
||||
@@ -531,8 +530,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('"control+c"').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { ctrlKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, {});
|
||||
});
|
||||
|
||||
test('filter matches with + separator in first and chord parts', async () => {
|
||||
@@ -543,8 +542,8 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('"shift+meta+escape ctrl+c"').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches.chordPart, { keyCode: true, ctrlKey: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { shiftKey: true, metaKey: true, keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.chordPart, { keyCode: true, ctrlKey: true });
|
||||
});
|
||||
|
||||
test('filter exact matches with space #32993', async () => {
|
||||
@@ -566,7 +565,7 @@ suite('KeybindingsEditorModel test', () => {
|
||||
await testObject.resolve({});
|
||||
const actual = testObject.fetch('"down"').filter(element => element.keybindingItem.command === command);
|
||||
assert.equal(1, actual.length);
|
||||
assert.deepEqual(actual[0].keybindingMatches.firstPart, { keyCode: true });
|
||||
assert.deepEqual(actual[0].keybindingMatches!.firstPart, { keyCode: true });
|
||||
});
|
||||
|
||||
function prepareKeybindingService(...keybindingItems: ResolvedKeybindingItem[]): ResolvedKeybindingItem[] {
|
||||
@@ -592,7 +591,7 @@ suite('KeybindingsEditorModel test', () => {
|
||||
assert.equal(actual.command, expected.command);
|
||||
if (actual.when) {
|
||||
assert.ok(!!expected.when);
|
||||
assert.equal(actual.when.serialize(), expected.when.serialize());
|
||||
assert.equal(actual.when.serialize(), expected.when!.serialize());
|
||||
} else {
|
||||
assert.ok(!expected.when);
|
||||
}
|
||||
@@ -600,7 +599,7 @@ suite('KeybindingsEditorModel test', () => {
|
||||
|
||||
if (actual.resolvedKeybinding) {
|
||||
assert.ok(!!expected.resolvedKeybinding);
|
||||
assert.equal(actual.resolvedKeybinding.getLabel(), expected.resolvedKeybinding.getLabel());
|
||||
assert.equal(actual.resolvedKeybinding.getLabel(), expected.resolvedKeybinding!.getLabel());
|
||||
} else {
|
||||
assert.ok(!expected.resolvedKeybinding);
|
||||
}
|
||||
@@ -609,10 +608,10 @@ suite('KeybindingsEditorModel test', () => {
|
||||
function aResolvedKeybindingItem({ command, when, isDefault, firstPart, chordPart }: { command?: string, when?: string, isDefault?: boolean, firstPart?: { keyCode: KeyCode, modifiers?: Modifiers }, chordPart?: { keyCode: KeyCode, modifiers?: Modifiers } }): ResolvedKeybindingItem {
|
||||
const aSimpleKeybinding = function (part: { keyCode: KeyCode, modifiers?: Modifiers }): SimpleKeybinding {
|
||||
const { ctrlKey, shiftKey, altKey, metaKey } = part.modifiers || { ctrlKey: false, shiftKey: false, altKey: false, metaKey: false };
|
||||
return new SimpleKeybinding(ctrlKey, shiftKey, altKey, metaKey, part.keyCode);
|
||||
return new SimpleKeybinding(ctrlKey!, shiftKey!, altKey!, metaKey!, part.keyCode);
|
||||
};
|
||||
const keybinding = firstPart ? chordPart ? new ChordKeybinding(aSimpleKeybinding(firstPart), aSimpleKeybinding(chordPart)) : aSimpleKeybinding(firstPart) : null;
|
||||
return new ResolvedKeybindingItem(keybinding ? new USLayoutResolvedKeybinding(keybinding, OS) : null, command || 'some command', null, when ? ContextKeyExpr.deserialize(when) : null, isDefault === void 0 ? true : isDefault);
|
||||
return new ResolvedKeybindingItem(keybinding ? new USLayoutResolvedKeybinding(keybinding, OS) : null, command || 'some command', null, when ? ContextKeyExpr.deserialize(when) : null, isDefault === undefined ? true : isDefault);
|
||||
}
|
||||
|
||||
function asResolvedKeybindingItems(keybindingEntries: IKeybindingItemEntry[], keepUnassigned: boolean = false): ResolvedKeybindingItem[] {
|
||||
|
||||
@@ -13,7 +13,7 @@ suite('Preferences Model test', () => {
|
||||
private validator: (value: any) => string;
|
||||
|
||||
constructor(private settings: IConfigurationPropertySchema) {
|
||||
this.validator = createValidator(settings);
|
||||
this.validator = createValidator(settings)!;
|
||||
}
|
||||
|
||||
public accepts(input) {
|
||||
|
||||
Reference in New Issue
Block a user