mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Vscode merge (#4582)
* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd * fix issues with merges * bump node version in azpipe * replace license headers * remove duplicate launch task * fix build errors * fix build errors * fix tslint issues * working through package and linux build issues * more work * wip * fix packaged builds * working through linux build errors * wip * wip * wip * fix mac and linux file limits * iterate linux pipeline * disable editor typing * revert series to parallel * remove optimize vscode from linux * fix linting issues * revert testing change * add work round for new node * readd packaging for extensions * fix issue with angular not resolving decorator dependencies
This commit is contained in:
@@ -22,12 +22,16 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { EditorModel } from 'vs/workbench/common/editor';
|
||||
import { IFilterMetadata, IFilterResult, IGroupFilter, IKeybindingsEditorModel, ISearchResultGroup, ISetting, ISettingMatch, ISettingMatcher, ISettingsEditorModel, ISettingsGroup } from 'vs/workbench/services/preferences/common/preferences';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
|
||||
export const nullRange: IRange = { startLineNumber: -1, startColumn: -1, endLineNumber: -1, endColumn: -1 };
|
||||
export function isNullRange(range: IRange): boolean { return range.startLineNumber === -1 && range.startColumn === -1 && range.endLineNumber === -1 && range.endColumn === -1; }
|
||||
|
||||
export abstract class AbstractSettingsModel extends EditorModel {
|
||||
|
||||
protected _currentResultGroups = new Map<string, ISearchResultGroup>();
|
||||
|
||||
updateResultGroup(id: string, resultGroup: ISearchResultGroup): IFilterResult {
|
||||
updateResultGroup(id: string, resultGroup: ISearchResultGroup | undefined): IFilterResult | undefined {
|
||||
if (resultGroup) {
|
||||
this._currentResultGroups.set(id, resultGroup);
|
||||
} else {
|
||||
@@ -44,9 +48,9 @@ export abstract class AbstractSettingsModel extends EditorModel {
|
||||
private removeDuplicateResults(): void {
|
||||
const settingKeys = new Set<string>();
|
||||
map.keys(this._currentResultGroups)
|
||||
.sort((a, b) => this._currentResultGroups.get(a).order - this._currentResultGroups.get(b).order)
|
||||
.sort((a, b) => this._currentResultGroups.get(a)!.order - this._currentResultGroups.get(b)!.order)
|
||||
.forEach(groupId => {
|
||||
const group = this._currentResultGroups.get(groupId);
|
||||
const group = this._currentResultGroups.get(groupId)!;
|
||||
group.result.filterMatches = group.result.filterMatches.filter(s => !settingKeys.has(s.setting.key));
|
||||
group.result.filterMatches.forEach(s => settingKeys.add(s.setting.key));
|
||||
});
|
||||
@@ -76,7 +80,7 @@ export abstract class AbstractSettingsModel extends EditorModel {
|
||||
return filterMatches.sort((a, b) => b.score - a.score);
|
||||
}
|
||||
|
||||
getPreference(key: string): ISetting {
|
||||
getPreference(key: string): ISetting | undefined {
|
||||
for (const group of this.settingsGroups) {
|
||||
for (const section of group.sections) {
|
||||
for (const setting of section.settings) {
|
||||
@@ -86,7 +90,8 @@ export abstract class AbstractSettingsModel extends EditorModel {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
protected collectMetadata(groups: ISearchResultGroup[]): IStringDictionary<IFilterMetadata> {
|
||||
@@ -111,12 +116,12 @@ export abstract class AbstractSettingsModel extends EditorModel {
|
||||
|
||||
abstract findValueMatches(filter: string, setting: ISetting): IRange[];
|
||||
|
||||
protected abstract update(): IFilterResult;
|
||||
protected abstract update(): IFilterResult | undefined;
|
||||
}
|
||||
|
||||
export class SettingsEditorModel extends AbstractSettingsModel implements ISettingsEditorModel {
|
||||
|
||||
private _settingsGroups: ISettingsGroup[];
|
||||
private _settingsGroups: ISettingsGroup[] | undefined;
|
||||
protected settingsModel: ITextModel;
|
||||
|
||||
private readonly _onDidChangeGroups: Emitter<void> = this._register(new Emitter<void>());
|
||||
@@ -124,10 +129,10 @@ export class SettingsEditorModel extends AbstractSettingsModel implements ISetti
|
||||
|
||||
constructor(reference: IReference<ITextEditorModel>, private _configurationTarget: ConfigurationTarget) {
|
||||
super();
|
||||
this.settingsModel = reference.object.textEditorModel;
|
||||
this.settingsModel = reference.object.textEditorModel!;
|
||||
this._register(this.onDispose(() => reference.dispose()));
|
||||
this._register(this.settingsModel.onDidChangeContent(() => {
|
||||
this._settingsGroups = null;
|
||||
this._settingsGroups = undefined;
|
||||
this._onDidChangeGroups.fire();
|
||||
}));
|
||||
}
|
||||
@@ -144,7 +149,7 @@ export class SettingsEditorModel extends AbstractSettingsModel implements ISetti
|
||||
if (!this._settingsGroups) {
|
||||
this.parse();
|
||||
}
|
||||
return this._settingsGroups;
|
||||
return this._settingsGroups!;
|
||||
}
|
||||
|
||||
get content(): string {
|
||||
@@ -163,10 +168,10 @@ export class SettingsEditorModel extends AbstractSettingsModel implements ISetti
|
||||
this._settingsGroups = parse(this.settingsModel, (property: string, previousParents: string[]): boolean => this.isSettingsProperty(property, previousParents));
|
||||
}
|
||||
|
||||
protected update(): IFilterResult {
|
||||
protected update(): IFilterResult | undefined {
|
||||
const resultGroups = map.values(this._currentResultGroups);
|
||||
if (!resultGroups.length) {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Transform resultGroups into IFilterResult - ISetting ranges are already correct here
|
||||
@@ -175,11 +180,13 @@ export class SettingsEditorModel extends AbstractSettingsModel implements ISetti
|
||||
resultGroups.forEach(group => {
|
||||
group.result.filterMatches.forEach(filterMatch => {
|
||||
filteredSettings.push(filterMatch.setting);
|
||||
matches.push(...filterMatch.matches);
|
||||
if (filterMatch.matches) {
|
||||
matches.push(...filterMatch.matches);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
let filteredGroup: ISettingsGroup;
|
||||
let filteredGroup: ISettingsGroup | undefined;
|
||||
const modelGroup = this.settingsGroups[0]; // Editable model has one or zero groups
|
||||
if (modelGroup) {
|
||||
filteredGroup = {
|
||||
@@ -216,12 +223,16 @@ export class Settings2EditorModel extends AbstractSettingsModel implements ISett
|
||||
) {
|
||||
super();
|
||||
|
||||
configurationService.onDidChangeConfiguration(e => {
|
||||
this._register(configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.source === ConfigurationTarget.DEFAULT) {
|
||||
this.dirty = true;
|
||||
this._onDidChangeGroups.fire();
|
||||
}
|
||||
});
|
||||
}));
|
||||
this._register(Registry.as<IConfigurationRegistry>(Extensions.Configuration).onDidSchemaChange(e => {
|
||||
this.dirty = true;
|
||||
this._onDidChangeGroups.fire();
|
||||
}));
|
||||
}
|
||||
|
||||
protected get filterGroups(): ISettingsGroup[] {
|
||||
@@ -268,7 +279,7 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
}
|
||||
if (previousParents.length === settingsPropertyIndex + 1 || (previousParents.length === settingsPropertyIndex + 2 && overrideSetting !== null)) {
|
||||
// settings value started
|
||||
const setting = previousParents.length === settingsPropertyIndex + 1 ? settings[settings.length - 1] : overrideSetting.overrides[overrideSetting.overrides.length - 1];
|
||||
const setting = previousParents.length === settingsPropertyIndex + 1 ? settings[settings.length - 1] : overrideSetting!.overrides![overrideSetting!.overrides!.length - 1];
|
||||
if (setting) {
|
||||
const valueStartPosition = model.getPositionAt(offset);
|
||||
const valueEndPosition = model.getPositionAt(offset + length);
|
||||
@@ -288,7 +299,7 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
}
|
||||
const visitor: JSONVisitor = {
|
||||
onObjectBegin: (offset: number, length: number) => {
|
||||
if (isSettingsProperty(currentProperty, previousParents)) {
|
||||
if (isSettingsProperty(currentProperty!, previousParents)) {
|
||||
// Settings started
|
||||
settingsPropertyIndex = previousParents.length;
|
||||
const position = model.getPositionAt(offset);
|
||||
@@ -323,10 +334,10 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
endColumn: 0
|
||||
},
|
||||
value: null,
|
||||
valueRange: null,
|
||||
descriptionRanges: null,
|
||||
valueRange: nullRange,
|
||||
descriptionRanges: [],
|
||||
overrides: [],
|
||||
overrideOf: overrideSetting
|
||||
overrideOf: withNullAsUndefined(overrideSetting)
|
||||
};
|
||||
if (previousParents.length === settingsPropertyIndex + 1) {
|
||||
settings.push(setting);
|
||||
@@ -334,7 +345,7 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
overrideSetting = setting;
|
||||
}
|
||||
} else {
|
||||
overrideSetting.overrides.push(setting);
|
||||
overrideSetting!.overrides!.push(setting);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -342,7 +353,7 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
currentParent = previousParents.pop();
|
||||
if (previousParents.length === settingsPropertyIndex + 1 || (previousParents.length === settingsPropertyIndex + 2 && overrideSetting !== null)) {
|
||||
// setting ended
|
||||
const setting = previousParents.length === settingsPropertyIndex + 1 ? settings[settings.length - 1] : overrideSetting.overrides[overrideSetting.overrides.length - 1];
|
||||
const setting = previousParents.length === settingsPropertyIndex + 1 ? settings[settings.length - 1] : overrideSetting!.overrides![overrideSetting!.overrides!.length - 1];
|
||||
if (setting) {
|
||||
const valueEndPosition = model.getPositionAt(offset + length);
|
||||
setting.valueRange = assign(setting.valueRange, {
|
||||
@@ -377,7 +388,7 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
currentParent = previousParents.pop();
|
||||
if (previousParents.length === settingsPropertyIndex + 1 || (previousParents.length === settingsPropertyIndex + 2 && overrideSetting !== null)) {
|
||||
// setting value ended
|
||||
const setting = previousParents.length === settingsPropertyIndex + 1 ? settings[settings.length - 1] : overrideSetting.overrides[overrideSetting.overrides.length - 1];
|
||||
const setting = previousParents.length === settingsPropertyIndex + 1 ? settings[settings.length - 1] : overrideSetting!.overrides![overrideSetting!.overrides!.length - 1];
|
||||
if (setting) {
|
||||
const valueEndPosition = model.getPositionAt(offset + length);
|
||||
setting.valueRange = assign(setting.valueRange, {
|
||||
@@ -394,7 +405,7 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
onLiteralValue: onValue,
|
||||
onError: (error) => {
|
||||
const setting = settings[settings.length - 1];
|
||||
if (setting && (!setting.range || !setting.keyRange || !setting.valueRange)) {
|
||||
if (setting && (isNullRange(setting.range) || isNullRange(setting.keyRange) || isNullRange(setting.valueRange))) {
|
||||
settings.pop();
|
||||
}
|
||||
}
|
||||
@@ -408,8 +419,8 @@ function parse(model: ITextModel, isSettingsProperty: (currentProperty: string,
|
||||
settings
|
||||
}
|
||||
],
|
||||
title: null,
|
||||
titleRange: null,
|
||||
title: '',
|
||||
titleRange: nullRange,
|
||||
range
|
||||
}] : [];
|
||||
}
|
||||
@@ -435,8 +446,6 @@ export class WorkspaceConfigurationEditorModel extends SettingsEditorModel {
|
||||
|
||||
export class DefaultSettings extends Disposable {
|
||||
|
||||
private static _RAW: string;
|
||||
|
||||
private _allSettingsGroups: ISettingsGroup[];
|
||||
private _content: string;
|
||||
private _settingsByName: Map<string, ISetting>;
|
||||
@@ -479,15 +488,7 @@ export class DefaultSettings extends Disposable {
|
||||
return [mostCommonlyUsed, ...settingsGroups];
|
||||
}
|
||||
|
||||
get raw(): string {
|
||||
if (!DefaultSettings._RAW) {
|
||||
DefaultSettings._RAW = this.toContent(this.getRegisteredGroups());
|
||||
}
|
||||
|
||||
return DefaultSettings._RAW;
|
||||
}
|
||||
|
||||
private getRegisteredGroups(): ISettingsGroup[] {
|
||||
getRegisteredGroups(): ISettingsGroup[] {
|
||||
const configurations = Registry.as<IConfigurationRegistry>(Extensions.Configuration).getConfigurations().slice();
|
||||
const groups = this.removeEmptySettingsGroups(configurations.sort(this.compareConfigurationNodes)
|
||||
.reduce((result, config, index, array) => this.parseConfig(config, result, array), []));
|
||||
@@ -524,13 +525,15 @@ export class DefaultSettings extends Disposable {
|
||||
description: setting.description,
|
||||
key: setting.key,
|
||||
value: setting.value,
|
||||
range: null,
|
||||
valueRange: null,
|
||||
keyRange: nullRange,
|
||||
range: nullRange,
|
||||
valueRange: nullRange,
|
||||
overrides: [],
|
||||
scope: ConfigurationScope.RESOURCE,
|
||||
type: setting.type,
|
||||
enum: setting.enum,
|
||||
enumDescriptions: setting.enumDescriptions
|
||||
enumDescriptions: setting.enumDescriptions,
|
||||
descriptionRanges: []
|
||||
};
|
||||
}
|
||||
return null;
|
||||
@@ -538,9 +541,9 @@ export class DefaultSettings extends Disposable {
|
||||
|
||||
return <ISettingsGroup>{
|
||||
id: 'mostCommonlyUsed',
|
||||
range: null,
|
||||
range: nullRange,
|
||||
title: nls.localize('commonlyUsed', "Commonly Used"),
|
||||
titleRange: null,
|
||||
titleRange: nullRange,
|
||||
sections: [
|
||||
{
|
||||
settings
|
||||
@@ -562,7 +565,7 @@ export class DefaultSettings extends Disposable {
|
||||
if (!settingsGroup) {
|
||||
settingsGroup = find(result, g => g.title === title);
|
||||
if (!settingsGroup) {
|
||||
settingsGroup = { sections: [{ settings: [] }], id: config.id, title: title, titleRange: null, range: null, contributedByExtension: !!config.contributedByExtension };
|
||||
settingsGroup = { sections: [{ settings: [] }], id: config.id || '', title: title || '', titleRange: nullRange, range: nullRange, contributedByExtension: !!config.contributedByExtension };
|
||||
result.push(settingsGroup);
|
||||
}
|
||||
} else {
|
||||
@@ -571,7 +574,7 @@ export class DefaultSettings extends Disposable {
|
||||
}
|
||||
if (config.properties) {
|
||||
if (!settingsGroup) {
|
||||
settingsGroup = { sections: [{ settings: [] }], id: config.id, title: config.id, titleRange: null, range: null, contributedByExtension: !!config.contributedByExtension };
|
||||
settingsGroup = { sections: [{ settings: [] }], id: config.id || '', title: config.id || '', titleRange: nullRange, range: nullRange, contributedByExtension: !!config.contributedByExtension };
|
||||
result.push(settingsGroup);
|
||||
}
|
||||
const configurationSettings: ISetting[] = [];
|
||||
@@ -615,9 +618,9 @@ export class DefaultSettings extends Disposable {
|
||||
value,
|
||||
description,
|
||||
descriptionIsMarkdown: !prop.description,
|
||||
range: null,
|
||||
keyRange: null,
|
||||
valueRange: null,
|
||||
range: nullRange,
|
||||
keyRange: nullRange,
|
||||
valueRange: nullRange,
|
||||
descriptionRanges: [],
|
||||
overrides,
|
||||
scope: prop.scope,
|
||||
@@ -640,9 +643,9 @@ export class DefaultSettings extends Disposable {
|
||||
value: overrideSettings[key],
|
||||
description: [],
|
||||
descriptionIsMarkdown: false,
|
||||
range: null,
|
||||
keyRange: null,
|
||||
valueRange: null,
|
||||
range: nullRange,
|
||||
keyRange: nullRange,
|
||||
valueRange: nullRange,
|
||||
descriptionRanges: [],
|
||||
overrides: []
|
||||
}));
|
||||
@@ -701,7 +704,7 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
|
||||
super();
|
||||
|
||||
this._register(defaultSettings.onDidChange(() => this._onDidChangeGroups.fire()));
|
||||
this._model = reference.object.textEditorModel;
|
||||
this._model = reference.object.textEditorModel!;
|
||||
this._register(this.onDispose(() => reference.dispose()));
|
||||
}
|
||||
|
||||
@@ -722,9 +725,9 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
|
||||
return this.settingsGroups.slice(1);
|
||||
}
|
||||
|
||||
protected update(): IFilterResult {
|
||||
protected update(): IFilterResult | undefined {
|
||||
if (this._model.isDisposed()) {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Grab current result groups, only render non-empty groups
|
||||
@@ -744,7 +747,7 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
|
||||
matches,
|
||||
metadata
|
||||
} :
|
||||
null;
|
||||
undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -835,10 +838,10 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
|
||||
overrideOf: setting.overrideOf,
|
||||
tags: setting.tags,
|
||||
deprecationMessage: setting.deprecationMessage,
|
||||
keyRange: undefined,
|
||||
valueRange: undefined,
|
||||
keyRange: nullRange,
|
||||
valueRange: nullRange,
|
||||
descriptionIsMarkdown: undefined,
|
||||
descriptionRanges: undefined
|
||||
descriptionRanges: []
|
||||
};
|
||||
}
|
||||
|
||||
@@ -846,7 +849,7 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
|
||||
return [];
|
||||
}
|
||||
|
||||
getPreference(key: string): ISetting {
|
||||
getPreference(key: string): ISetting | undefined {
|
||||
for (const group of this.settingsGroups) {
|
||||
for (const section of group.sections) {
|
||||
for (const setting of section.settings) {
|
||||
@@ -856,15 +859,15 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private getGroup(resultGroup: ISearchResultGroup): ISettingsGroup {
|
||||
return <ISettingsGroup>{
|
||||
id: resultGroup.id,
|
||||
range: null,
|
||||
range: nullRange,
|
||||
title: resultGroup.label,
|
||||
titleRange: null,
|
||||
titleRange: nullRange,
|
||||
sections: [
|
||||
{
|
||||
settings: resultGroup.result.filterMatches.map(m => this.copySetting(m.setting))
|
||||
@@ -889,10 +892,6 @@ class SettingsContentBuilder {
|
||||
this._contentByLines = [];
|
||||
}
|
||||
|
||||
private offsetIndexToIndex(offsetIdx: number): number {
|
||||
return offsetIdx - this._rangeOffset;
|
||||
}
|
||||
|
||||
pushLine(...lineText: string[]): void {
|
||||
this._contentByLines.push(...lineText);
|
||||
}
|
||||
@@ -901,11 +900,11 @@ class SettingsContentBuilder {
|
||||
this._contentByLines.push('{');
|
||||
this._contentByLines.push('');
|
||||
this._contentByLines.push('');
|
||||
const lastSetting = this._pushGroup(settingsGroups);
|
||||
const lastSetting = this._pushGroup(settingsGroups, ' ');
|
||||
|
||||
if (lastSetting) {
|
||||
// Strip the comma from the last setting
|
||||
const lineIdx = this.offsetIndexToIndex(lastSetting.range.endLineNumber);
|
||||
const lineIdx = lastSetting.range.endLineNumber - this._rangeOffset;
|
||||
const content = this._contentByLines[lineIdx - 2];
|
||||
this._contentByLines[lineIdx - 2] = content.substring(0, content.length - 1);
|
||||
}
|
||||
@@ -913,8 +912,7 @@ class SettingsContentBuilder {
|
||||
this._contentByLines.push('}');
|
||||
}
|
||||
|
||||
private _pushGroup(group: ISettingsGroup): ISetting {
|
||||
const indent = ' ';
|
||||
protected _pushGroup(group: ISettingsGroup, indent: string): ISetting | null {
|
||||
let lastSetting: ISetting | null = null;
|
||||
const groupStart = this.lineCountWithOffset + 1;
|
||||
for (const section of group.sections) {
|
||||
@@ -974,12 +972,12 @@ class SettingsContentBuilder {
|
||||
|
||||
if (setting.enumDescriptions && setting.enumDescriptions.some(desc => !!desc)) {
|
||||
setting.enumDescriptions.forEach((desc, i) => {
|
||||
const displayEnum = escapeInvisibleChars(String(setting.enum[i]));
|
||||
const displayEnum = escapeInvisibleChars(String(setting.enum![i]));
|
||||
const line = desc ?
|
||||
`${displayEnum}: ${fixSettingLink(desc)}` :
|
||||
displayEnum;
|
||||
|
||||
this._contentByLines.push(` // - ${line}`);
|
||||
this._contentByLines.push(`${indent}// - ${line}`);
|
||||
|
||||
setting.descriptionRanges.push({ startLineNumber: this.lineCountWithOffset, startColumn: this.lastLine.indexOf(line) + 1, endLineNumber: this.lineCountWithOffset, endColumn: this.lastLine.length });
|
||||
});
|
||||
@@ -989,7 +987,7 @@ class SettingsContentBuilder {
|
||||
private pushValue(setting: ISetting, preValueConent: string, indent: string): void {
|
||||
const valueString = JSON.stringify(setting.value, null, indent);
|
||||
if (valueString && (typeof setting.value === 'object')) {
|
||||
if (setting.overrides.length) {
|
||||
if (setting.overrides && setting.overrides.length) {
|
||||
this._contentByLines.push(preValueConent + ' {');
|
||||
for (const subSetting of setting.overrides) {
|
||||
this.pushSetting(subSetting, indent + indent);
|
||||
@@ -1018,7 +1016,7 @@ class SettingsContentBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
export function createValidator(prop: IConfigurationPropertySchema): ((value: any) => string) | null {
|
||||
export function createValidator(prop: IConfigurationPropertySchema): (value: any) => (string | null) {
|
||||
return value => {
|
||||
let exclusiveMax: number | undefined;
|
||||
let exclusiveMin: number | undefined;
|
||||
@@ -1052,28 +1050,28 @@ export function createValidator(prop: IConfigurationPropertySchema): ((value: an
|
||||
const numericValidations: Validator<number>[] = isNumeric ? [
|
||||
{
|
||||
enabled: exclusiveMax !== undefined && (prop.maximum === undefined || exclusiveMax <= prop.maximum),
|
||||
isValid: (value => value < exclusiveMax),
|
||||
isValid: (value => value < exclusiveMax!),
|
||||
message: nls.localize('validations.exclusiveMax', "Value must be strictly less than {0}.", exclusiveMax)
|
||||
},
|
||||
{
|
||||
enabled: exclusiveMin !== undefined && (prop.minimum === undefined || exclusiveMin >= prop.minimum),
|
||||
isValid: (value => value > exclusiveMin),
|
||||
isValid: (value => value > exclusiveMin!),
|
||||
message: nls.localize('validations.exclusiveMin', "Value must be strictly greater than {0}.", exclusiveMin)
|
||||
},
|
||||
|
||||
{
|
||||
enabled: prop.maximum !== undefined && (exclusiveMax === undefined || exclusiveMax > prop.maximum),
|
||||
isValid: (value => value <= prop.maximum),
|
||||
isValid: (value => value <= prop.maximum!),
|
||||
message: nls.localize('validations.max', "Value must be less than or equal to {0}.", prop.maximum)
|
||||
},
|
||||
{
|
||||
enabled: prop.minimum !== undefined && (exclusiveMin === undefined || exclusiveMin < prop.minimum),
|
||||
isValid: (value => value >= prop.minimum),
|
||||
isValid: (value => value >= prop.minimum!),
|
||||
message: nls.localize('validations.min', "Value must be greater than or equal to {0}.", prop.minimum)
|
||||
},
|
||||
{
|
||||
enabled: prop.multipleOf !== undefined,
|
||||
isValid: (value => value % prop.multipleOf === 0),
|
||||
isValid: (value => value % prop.multipleOf! === 0),
|
||||
message: nls.localize('validations.multipleOf', "Value must be a multiple of {0}.", prop.multipleOf)
|
||||
},
|
||||
{
|
||||
@@ -1086,17 +1084,17 @@ export function createValidator(prop: IConfigurationPropertySchema): ((value: an
|
||||
const stringValidations: Validator<string>[] = [
|
||||
{
|
||||
enabled: prop.maxLength !== undefined,
|
||||
isValid: (value => value.length <= prop.maxLength),
|
||||
isValid: (value => value.length <= prop.maxLength!),
|
||||
message: nls.localize('validations.maxLength', "Value must be {0} or fewer characters long.", prop.maxLength)
|
||||
},
|
||||
{
|
||||
enabled: prop.minLength !== undefined,
|
||||
isValid: (value => value.length >= prop.minLength),
|
||||
isValid: (value => value.length >= prop.minLength!),
|
||||
message: nls.localize('validations.minLength', "Value must be {0} or more characters long.", prop.minLength)
|
||||
},
|
||||
{
|
||||
enabled: patternRegex !== undefined,
|
||||
isValid: (value => patternRegex.test(value)),
|
||||
isValid: (value => patternRegex!.test(value)),
|
||||
message: prop.patternErrorMessage || nls.localize('validations.regex', "Value must match regex `{0}`.", prop.pattern)
|
||||
},
|
||||
].filter(validation => validation.enabled);
|
||||
@@ -1124,6 +1122,41 @@ export function createValidator(prop: IConfigurationPropertySchema): ((value: an
|
||||
};
|
||||
}
|
||||
|
||||
class RawSettingsContentBuilder extends SettingsContentBuilder {
|
||||
|
||||
constructor(private indent: string = '\t') {
|
||||
super(0);
|
||||
}
|
||||
|
||||
pushGroup(settingsGroups: ISettingsGroup): void {
|
||||
this._pushGroup(settingsGroups, this.indent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class DefaultRawSettingsEditorModel extends Disposable {
|
||||
|
||||
private _content: string | null = null;
|
||||
|
||||
constructor(private defaultSettings: DefaultSettings) {
|
||||
super();
|
||||
this._register(defaultSettings.onDidChange(() => this._content = null));
|
||||
}
|
||||
|
||||
get content(): string {
|
||||
if (this._content === null) {
|
||||
const builder = new RawSettingsContentBuilder();
|
||||
builder.pushLine('{');
|
||||
for (const settingsGroup of this.defaultSettings.getRegisteredGroups()) {
|
||||
builder.pushGroup(settingsGroup);
|
||||
}
|
||||
builder.pushLine('}');
|
||||
this._content = builder.getContent();
|
||||
}
|
||||
return this._content;
|
||||
}
|
||||
}
|
||||
|
||||
function escapeInvisibleChars(enumValue: string): string {
|
||||
return enumValue && enumValue
|
||||
.replace(/\n/g, '\\n')
|
||||
|
||||
Reference in New Issue
Block a user