This commit is contained in:
Sandeep Somavarapu 2020-08-05 13:51:21 +02:00
parent 144f90443a
commit 530e947fe5
15 changed files with 126 additions and 44 deletions

View file

@ -42,11 +42,11 @@ export class SettingsDocument {
});
}
// sync.ignoredExtensions
if (location.path[0] === 'sync.ignoredExtensions') {
// settingsSync.ignoredExtensions
if (location.path[0] === 'settingsSync.ignoredExtensions') {
let ignoredExtensions = [];
try {
ignoredExtensions = parse(this.document.getText())['sync.ignoredExtensions'];
ignoredExtensions = parse(this.document.getText())['settingsSync.ignoredExtensions'];
} catch (e) {/* ignore error */ }
return provideInstalledExtensionProposals(ignoredExtensions, range, true);
}

View file

@ -205,7 +205,7 @@ function massageOutgoingExtension(extension: ISyncExtension, key: string): ISync
export function getIgnoredExtensions(installed: ILocalExtension[], configurationService: IConfigurationService): string[] {
const defaultIgnoredExtensions = installed.filter(i => i.isMachineScoped).map(i => i.identifier.id.toLowerCase());
const value = (configurationService.getValue<string[]>('sync.ignoredExtensions') || []).map(id => id.toLowerCase());
const value = getConfiguredIgnoredExtensions(configurationService).map(id => id.toLowerCase());
const added: string[] = [], removed: string[] = [];
if (Array.isArray(value)) {
for (const key of value) {
@ -218,3 +218,15 @@ export function getIgnoredExtensions(installed: ILocalExtension[], configuration
}
return distinct([...defaultIgnoredExtensions, ...added,].filter(setting => removed.indexOf(setting) === -1));
}
function getConfiguredIgnoredExtensions(configurationService: IConfigurationService): string[] {
let userValue = configurationService.inspect<string[]>('settingsSync.ignoredExtensions').userValue;
if (userValue !== undefined) {
return userValue;
}
userValue = configurationService.inspect<string[]>('sync.ignoredExtensions').userValue;
if (userValue !== undefined) {
return userValue;
}
return configurationService.getValue<string[]>('settingsSync.ignoredExtensions') || [];
}

View file

@ -45,10 +45,14 @@ interface ILastSyncUserData extends IRemoteUserData {
export class ExtensionsSynchroniser extends AbstractSynchroniser implements IUserDataSynchroniser {
private static readonly EXTENSIONS_DATA_URI = URI.from({ scheme: USER_DATA_SYNC_SCHEME, authority: 'extensions', path: `/extensions.json` });
/*
Version 3 - Introduce installed property to skip installing built in extensions
protected readonly version: number = 3;
*/
protected readonly version: number = 3;
/* Version 4: Change settings from `sync.${setting}` to `settingsSync.{setting}` */
protected readonly version: number = 4;
protected isEnabled(): boolean { return super.isEnabled() && this.extensionGalleryService.isEnabled(); }
private readonly previewResource: URI = joinPath(this.syncPreviewFolder, 'extensions.json');
private readonly localResource: URI = this.previewResource.with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'local' });

View file

@ -37,7 +37,8 @@ interface IKeybindingsResourcePreview extends IFileResourcePreview {
export class KeybindingsSynchroniser extends AbstractJsonFileSynchroniser implements IUserDataSynchroniser {
protected readonly version: number = 1;
/* Version 2: Change settings from `sync.${setting}` to `settingsSync.{setting}` */
protected readonly version: number = 2;
private readonly previewResource: URI = joinPath(this.syncPreviewFolder, 'keybindings.json');
private readonly localResource: URI = this.previewResource.with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'local' });
private readonly remoteResource: URI = this.previewResource.with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'remote' });
@ -262,7 +263,7 @@ export class KeybindingsSynchroniser extends AbstractJsonFileSynchroniser implem
getKeybindingsContentFromSyncContent(syncContent: string): string | null {
try {
const parsed = <ISyncContent>JSON.parse(syncContent);
if (!this.configurationService.getValue<boolean>('sync.keybindingsPerPlatform')) {
if (!this.syncKeybindingsPerPlatform()) {
return isUndefined(parsed.all) ? null : parsed.all;
}
switch (OS) {
@ -286,7 +287,7 @@ export class KeybindingsSynchroniser extends AbstractJsonFileSynchroniser implem
} catch (e) {
this.logService.error(e);
}
if (!this.configurationService.getValue<boolean>('sync.keybindingsPerPlatform')) {
if (!this.syncKeybindingsPerPlatform()) {
parsed.all = keybindingsContent;
} else {
delete parsed.all;
@ -305,4 +306,16 @@ export class KeybindingsSynchroniser extends AbstractJsonFileSynchroniser implem
return JSON.stringify(parsed);
}
private syncKeybindingsPerPlatform(): boolean {
let userValue = this.configurationService.inspect<boolean>('settingsSync.keybindingsPerPlatform').userValue;
if (userValue !== undefined) {
return userValue;
}
userValue = this.configurationService.inspect<boolean>('sync.keybindingsPerPlatform').userValue;
if (userValue !== undefined) {
return userValue;
}
return this.configurationService.getValue<boolean>('settingsSync.keybindingsPerPlatform');
}
}

View file

@ -23,12 +23,9 @@ export interface IMergeResult {
export function getIgnoredSettings(defaultIgnoredSettings: string[], configurationService: IConfigurationService, settingsContent?: string): string[] {
let value: string[] = [];
if (settingsContent) {
const setting = parse(settingsContent);
if (setting) {
value = setting['sync.ignoredSettings'];
}
value = getIgnoredSettingsFromContent(settingsContent);
} else {
value = configurationService.getValue<string[]>('sync.ignoredSettings');
value = getIgnoredSettingsFromConfig(configurationService);
}
const added: string[] = [], removed: string[] = [...getDisallowedIgnoredSettings()];
if (Array.isArray(value)) {
@ -43,6 +40,22 @@ export function getIgnoredSettings(defaultIgnoredSettings: string[], configurati
return distinct([...defaultIgnoredSettings, ...added,].filter(setting => removed.indexOf(setting) === -1));
}
function getIgnoredSettingsFromConfig(configurationService: IConfigurationService): string[] {
let userValue = configurationService.inspect<string[]>('settingsSync.ignoredSettings').userValue;
if (userValue !== undefined) {
return userValue;
}
userValue = configurationService.inspect<string[]>('sync.ignoredSettings').userValue;
if (userValue !== undefined) {
return userValue;
}
return configurationService.getValue<string[]>('settingsSync.ignoredSettings') || [];
}
function getIgnoredSettingsFromContent(settingsContent: string): string[] {
const parsed = parse(settingsContent);
return parsed ? parsed['settingsSync.ignoredSettings'] || parsed['sync.ignoredSettings'] || [] : [];
}
export function updateIgnoredSettings(targetContent: string, sourceContent: string, ignoredSettings: string[], formattingOptions: FormattingOptions): string {
if (ignoredSettings.length) {

View file

@ -42,7 +42,8 @@ function isSettingsSyncContent(thing: any): thing is ISettingsSyncContent {
export class SettingsSynchroniser extends AbstractJsonFileSynchroniser implements IUserDataSynchroniser {
protected readonly version: number = 1;
/* Version 2: Change settings from `sync.${setting}` to `settingsSync.{setting}` */
protected readonly version: number = 2;
readonly previewResource: URI = joinPath(this.syncPreviewFolder, 'settings.json');
readonly localResource: URI = this.previewResource.with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'local' });
readonly remoteResource: URI = this.previewResource.with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'remote' });

View file

@ -270,13 +270,13 @@ export class UserDataAutoSyncService extends UserDataAutoSyncEnablementService i
// Incompatible Local Content
else if (userDataSyncError.code === UserDataSyncErrorCode.IncompatibleLocalContent) {
await this.turnOff(false, true /* force soft turnoff on error */);
this.logService.info('Auto Sync: Turned off sync because server has {0} content with newer version than of client. Requires client upgrade.', userDataSyncError.resource);
this.logService.info(`Auto Sync: Turned off sync because server has ${userDataSyncError.resource} content with newer version than of client. Requires client upgrade.`);
}
// Incompatible Remote Content
else if (userDataSyncError.code === UserDataSyncErrorCode.IncompatibleRemoteContent) {
await this.turnOff(false, true /* force soft turnoff on error */);
this.logService.info('Auto Sync: Turned off sync because server has {0} content with older version than of client. Requires server reset.', userDataSyncError.resource);
this.logService.info(`Auto Sync: Turned off sync because server has ${userDataSyncError.resource} content with older version than of client. Requires server reset.`);
}
// Service changed

View file

@ -41,21 +41,25 @@ export function registerConfiguration(): IDisposable {
const ignoredExtensionsSchemaId = 'vscode://schemas/ignoredExtensions';
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
id: 'sync',
id: 'settingsSync',
order: 30,
title: localize('sync', "Sync"),
title: localize('settings sync', "Settings Sync"),
type: 'object',
properties: {
'sync.keybindingsPerPlatform': {
'settingsSync.keybindingsPerPlatform': {
type: 'boolean',
description: localize('sync.keybindingsPerPlatform', "Synchronize keybindings for each platform."),
description: localize('settingsSync.keybindingsPerPlatform', "Synchronize keybindings for each platform."),
default: true,
scope: ConfigurationScope.APPLICATION,
tags: ['sync', 'usesOnlineServices']
},
'sync.ignoredExtensions': {
'sync.keybindingsPerPlatform': {
type: 'boolean',
deprecationMessage: localize('sync.keybindingsPerPlatform.deprecated', "Deprecated, use settingsSync.keybindingsPerPlatform instead"),
},
'settingsSync.ignoredExtensions': {
'type': 'array',
'description': localize('sync.ignoredExtensions', "List of extensions to be ignored while synchronizing. The identifier of an extension is always ${publisher}.${name}. For example: vscode.csharp."),
'description': localize('settingsSync.ignoredExtensions', "List of extensions to be ignored while synchronizing. The identifier of an extension is always ${publisher}.${name}. For example: vscode.csharp."),
$ref: ignoredExtensionsSchemaId,
'default': [],
'scope': ConfigurationScope.APPLICATION,
@ -63,9 +67,13 @@ export function registerConfiguration(): IDisposable {
disallowSyncIgnore: true,
tags: ['sync', 'usesOnlineServices']
},
'sync.ignoredSettings': {
'sync.ignoredExtensions': {
'type': 'array',
description: localize('sync.ignoredSettings', "Configure settings to be ignored while synchronizing."),
deprecationMessage: localize('sync.ignoredExtensions.deprecated', "Deprecated, use settingsSync.ignoredExtensions instead"),
},
'settingsSync.ignoredSettings': {
'type': 'array',
description: localize('settingsSync.ignoredSettings', "Configure settings to be ignored while synchronizing."),
'default': [],
'scope': ConfigurationScope.APPLICATION,
$ref: ignoredSettingsSchemaId,
@ -73,6 +81,10 @@ export function registerConfiguration(): IDisposable {
uniqueItems: true,
disallowSyncIgnore: true,
tags: ['sync', 'usesOnlineServices']
},
'sync.ignoredSettings': {
'type': 'array',
deprecationMessage: localize('sync.ignoredSettings.deprecated', "Deprecated, use settingsSync.ignoredSettings instead"),
}
}
});

View file

@ -300,7 +300,7 @@ suite('SettingsSync - Auto', () => {
"workbench.colorTheme": "GitHub Sharp",
// Ignored
"sync.ignoredSettings": [
"settingsSync.ignoredSettings": [
"editor.fontFamily",
"terminal.integrated.shell.osx"
]
@ -321,7 +321,7 @@ suite('SettingsSync - Auto', () => {
"workbench.colorTheme": "GitHub Sharp",
// Ignored
"sync.ignoredSettings": [
"settingsSync.ignoredSettings": [
"editor.fontFamily",
"terminal.integrated.shell.osx"
]
@ -345,7 +345,7 @@ suite('SettingsSync - Auto', () => {
"workbench.colorTheme": "GitHub Sharp",
// Ignored
"sync.ignoredSettings": [
"settingsSync.ignoredSettings": [
"editor.fontFamily",
"terminal.integrated.shell.osx"
],
@ -369,7 +369,7 @@ suite('SettingsSync - Auto', () => {
"workbench.colorTheme": "GitHub Sharp",
// Ignored
"sync.ignoredSettings": [
"settingsSync.ignoredSettings": [
"editor.fontFamily",
"terminal.integrated.shell.osx"
],
@ -417,14 +417,14 @@ suite('SettingsSync - Auto', () => {
await updateSettings(JSON.stringify({
'a': 1,
'b': 2,
'sync.ignoredSettings': ['a']
'settingsSync.ignoredSettings': ['a']
}), client2);
await client2.sync();
await updateSettings(JSON.stringify({
'a': 2,
'b': 1,
'sync.ignoredSettings': ['a']
'settingsSync.ignoredSettings': ['a']
}), client);
await testObject.sync(await client.manifest());
@ -435,7 +435,7 @@ suite('SettingsSync - Auto', () => {
const mergeContent = (await fileService.readFile(testObject.conflicts[0].previewResource)).value.toString();
assert.deepEqual(JSON.parse(mergeContent), {
'b': 1,
'sync.ignoredSettings': ['a']
'settingsSync.ignoredSettings': ['a']
});
});
@ -474,7 +474,7 @@ suite('SettingsSync - Manual', () => {
"workbench.colorTheme": "GitHub Sharp",
// Ignored
"sync.ignoredSettings": [
"settingsSync.ignoredSettings": [
"editor.fontFamily",
"terminal.integrated.shell.osx"
]
@ -498,7 +498,7 @@ suite('SettingsSync - Manual', () => {
"workbench.colorTheme": "GitHub Sharp",
// Ignored
"sync.ignoredSettings": [
"settingsSync.ignoredSettings": [
"editor.fontFamily",
"terminal.integrated.shell.osx"
]

View file

@ -2785,7 +2785,7 @@ export class SyncIgnoredIconAction extends ExtensionAction {
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
) {
super('extensions.syncignore', '', SyncIgnoredIconAction.DISABLE_CLASS, false);
this._register(Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectedKeys.includes('sync.ignoredExtensions'))(() => this.update()));
this._register(Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectedKeys.includes('settingsSync.ignoredExtensions'))(() => this.update()));
this.update();
this.tooltip = localize('syncingore.label', "This extension is ignored during sync.");
}

View file

@ -977,7 +977,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
const id = extension.identifier.id.toLowerCase();
// first remove the extension completely from ignored extensions
let currentValue = [...this.configurationService.getValue<string[]>('sync.ignoredExtensions')].map(id => id.toLowerCase());
let currentValue = [...this.configurationService.getValue<string[]>('settingsSync.ignoredExtensions')].map(id => id.toLowerCase());
currentValue = currentValue.filter(v => v !== id && v !== `-${id}`);
// If ignored, then add only if it is ignored by default
@ -990,7 +990,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
currentValue.push(id);
}
return this.configurationService.updateValue('sync.ignoredExtensions', currentValue.length ? currentValue : undefined, ConfigurationTarget.USER);
return this.configurationService.updateValue('settingsSync.ignoredExtensions', currentValue.length ? currentValue : undefined, ConfigurationTarget.USER);
}
private installWithProgress<T>(installTask: () => Promise<T>, extensionName?: string): Promise<T> {

View file

@ -217,9 +217,9 @@ export const tocData: ITOCEntry = {
settings: ['telemetry.*']
},
{
id: 'application/sync',
label: localize('sync', "Sync"),
settings: ['sync.*']
id: 'application/settingsSync',
label: localize('settingsSync', "Settings Sync"),
settings: ['settingsSync.*']
}
]
}

View file

@ -499,7 +499,7 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre
this.ignoredSettings = getIgnoredSettings(getDefaultIgnoredSettings(), this._configService);
this._register(this._configService.onDidChangeConfiguration(e => {
if (e.affectedKeys.includes('sync.ignoredSettings')) {
if (e.affectedKeys.includes('settingsSync.ignoredSettings')) {
this.ignoredSettings = getIgnoredSettings(getDefaultIgnoredSettings(), this._configService);
this._onDidChangeIgnoredSettings.fire();
}
@ -2025,7 +2025,7 @@ class SyncSettingAction extends Action {
@IConfigurationService private readonly configService: IConfigurationService,
) {
super(SyncSettingAction.ID, SyncSettingAction.LABEL);
this._register(Event.filter(configService.onDidChangeConfiguration, e => e.affectsConfiguration('sync.ignoredSettings'))(() => this.update()));
this._register(Event.filter(configService.onDidChangeConfiguration, e => e.affectsConfiguration('settingsSync.ignoredSettings'))(() => this.update()));
this.update();
}
@ -2036,7 +2036,7 @@ class SyncSettingAction extends Action {
async run(): Promise<void> {
// first remove the current setting completely from ignored settings
let currentValue = [...this.configService.getValue<string[]>('sync.ignoredSettings')];
let currentValue = [...this.configService.getValue<string[]>('settingsSync.ignoredSettings')];
currentValue = currentValue.filter(v => v !== this.setting.key && v !== `-${this.setting.key}`);
const defaultIgnoredSettings = getDefaultIgnoredSettings();
@ -2053,7 +2053,7 @@ class SyncSettingAction extends Action {
currentValue.push(this.setting.key);
}
this.configService.updateValue('sync.ignoredSettings', currentValue.length ? currentValue : undefined, ConfigurationTarget.USER);
this.configService.updateValue('settingsSync.ignoredSettings', currentValue.length ? currentValue : undefined, ConfigurationTarget.USER);
return Promise.resolve(undefined);
}

View file

@ -12,6 +12,7 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
import { Disposable } from 'vs/base/common/lifecycle';
import { localize } from 'vs/nls';
import { isWeb } from 'vs/base/common/platform';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
class UserDataSyncReportIssueContribution extends Disposable implements IWorkbenchContribution {
@ -38,8 +39,34 @@ class UserDataSyncReportIssueContribution extends Disposable implements IWorkben
}
}
export class UserDataSyncSettingsMigrationContribution implements IWorkbenchContribution {
constructor(
@IConfigurationService private readonly configurationService: IConfigurationService
) {
this.migrateSettings();
}
private async migrateSettings(): Promise<void> {
await this.migrateSetting('sync.keybindingsPerPlatform', 'settingsSync.keybindingsPerPlatform');
await this.migrateSetting('sync.ignoredExtensions', 'settingsSync.ignoredExtensions');
await this.migrateSetting('sync.ignoredSettings', 'settingsSync.ignoredSettings');
}
private async migrateSetting(oldSetting: string, newSetting: string): Promise<void> {
const userValue = this.configurationService.inspect(oldSetting).userValue;
if (userValue !== undefined) {
// remove the old setting
await this.configurationService.updateValue(oldSetting, undefined, ConfigurationTarget.USER);
// add the new setting
await this.configurationService.updateValue(newSetting, userValue, ConfigurationTarget.USER);
}
}
}
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
workbenchRegistry.registerWorkbenchContribution(UserDataSyncWorkbenchContribution, LifecyclePhase.Ready);
workbenchRegistry.registerWorkbenchContribution(UserDataSyncSettingsMigrationContribution, LifecyclePhase.Eventually);
if (isWeb) {
workbenchRegistry.registerWorkbenchContribution(UserDataSyncReportIssueContribution, LifecyclePhase.Ready);

View file

@ -554,7 +554,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}, {
id: SyncResource.Keybindings,
label: getSyncAreaLabel(SyncResource.Keybindings),
description: this.configurationService.getValue('sync.keybindingsPerPlatform') ? localize('per platform', "for each platform") : undefined
description: this.configurationService.getValue('settingsSync.keybindingsPerPlatform') ? localize('per platform', "for each platform") : undefined
}, {
id: SyncResource.Snippets,
label: getSyncAreaLabel(SyncResource.Snippets)