mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
#138511 format only while displaying
This commit is contained in:
parent
35a17b1397
commit
10cdcbbe13
|
@ -146,10 +146,10 @@ export class ExtensionsSynchroniser extends AbstractSynchroniser implements IUse
|
|||
return [{
|
||||
skippedExtensions,
|
||||
localResource: this.localResource,
|
||||
localContent: this.stringify(localExtensions),
|
||||
localContent: this.stringify(localExtensions, false),
|
||||
localExtensions,
|
||||
remoteResource: this.remoteResource,
|
||||
remoteContent: remoteExtensions ? this.stringify(remoteExtensions) : null,
|
||||
remoteContent: remoteExtensions ? this.stringify(remoteExtensions, false) : null,
|
||||
previewResource: this.previewResource,
|
||||
previewResult,
|
||||
localChange: previewResult.localChange,
|
||||
|
@ -188,7 +188,7 @@ export class ExtensionsSynchroniser extends AbstractSynchroniser implements IUse
|
|||
preview.push(localExtension);
|
||||
}
|
||||
|
||||
return this.stringify(preview);
|
||||
return this.stringify(preview, false);
|
||||
}
|
||||
|
||||
protected async getMergeResult(resourcePreview: IExtensionResourcePreview, token: CancellationToken): Promise<IMergeResult> {
|
||||
|
@ -292,11 +292,12 @@ export class ExtensionsSynchroniser extends AbstractSynchroniser implements IUse
|
|||
const installedExtensions = await this.extensionManagementService.getInstalled();
|
||||
const ignoredExtensions = this.ignoredExtensionsManagementService.getIgnoredExtensions(installedExtensions);
|
||||
const localExtensions = this.getLocalExtensions(installedExtensions).filter(e => !ignoredExtensions.some(id => areSameExtensions({ id }, e.identifier)));
|
||||
return this.stringify(localExtensions);
|
||||
return this.stringify(localExtensions, true);
|
||||
}
|
||||
|
||||
if (this.extUri.isEqual(this.remoteResource, uri) || this.extUri.isEqual(this.localResource, uri) || this.extUri.isEqual(this.acceptedResource, uri)) {
|
||||
return this.resolvePreviewContent(uri);
|
||||
const content = await this.resolvePreviewContent(uri);
|
||||
return content ? this.stringify(JSON.parse(content), true) : content;
|
||||
}
|
||||
|
||||
let content = await super.resolveContent(uri);
|
||||
|
@ -310,7 +311,7 @@ export class ExtensionsSynchroniser extends AbstractSynchroniser implements IUse
|
|||
if (syncData) {
|
||||
switch (this.extUri.basename(uri)) {
|
||||
case 'extensions.json':
|
||||
return this.stringify(this.parseExtensions(syncData));
|
||||
return this.stringify(this.parseExtensions(syncData), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +319,7 @@ export class ExtensionsSynchroniser extends AbstractSynchroniser implements IUse
|
|||
return null;
|
||||
}
|
||||
|
||||
private stringify(extensions: ISyncExtension[]): string {
|
||||
private stringify(extensions: ISyncExtension[], format: boolean): string {
|
||||
extensions.sort((e1, e2) => {
|
||||
if (!e1.identifier.uuid && e2.identifier.uuid) {
|
||||
return -1;
|
||||
|
@ -328,7 +329,7 @@ export class ExtensionsSynchroniser extends AbstractSynchroniser implements IUse
|
|||
}
|
||||
return compare(e1.identifier.id, e2.identifier.id);
|
||||
});
|
||||
return JSON.stringify(extensions, null, '\t');
|
||||
return format ? JSON.stringify(extensions, null, '\t') : JSON.stringify(extensions);
|
||||
}
|
||||
|
||||
async hasLocalData(): Promise<boolean> {
|
||||
|
|
|
@ -43,12 +43,12 @@ export interface IGlobalStateResourcePreview extends IResourcePreview {
|
|||
readonly storageKeys: StorageKeys;
|
||||
}
|
||||
|
||||
function stringify(globalState: IGlobalState): string {
|
||||
function stringify(globalState: IGlobalState, format: boolean): string {
|
||||
const storageKeys = globalState.storage ? Object.keys(globalState.storage).sort() : [];
|
||||
const storage: IStringDictionary<IStorageValue> = {};
|
||||
storageKeys.forEach(key => storage[key] = globalState.storage[key]);
|
||||
globalState.storage = storage;
|
||||
return JSON.stringify(globalState, null, '\t');
|
||||
return format ? JSON.stringify(globalState, null, '\t') : JSON.stringify(globalState);
|
||||
}
|
||||
|
||||
const GLOBAL_STATE_DATA_VERSION = 1;
|
||||
|
@ -124,10 +124,10 @@ export class GlobalStateSynchroniser extends AbstractSynchroniser implements IUs
|
|||
|
||||
return [{
|
||||
localResource: this.localResource,
|
||||
localContent: stringify(localGlobalState),
|
||||
localContent: stringify(localGlobalState, false),
|
||||
localUserData: localGlobalState,
|
||||
remoteResource: this.remoteResource,
|
||||
remoteContent: remoteGlobalState ? stringify(remoteGlobalState) : null,
|
||||
remoteContent: remoteGlobalState ? stringify(remoteGlobalState, false) : null,
|
||||
previewResource: this.previewResource,
|
||||
previewResult,
|
||||
localChange: previewResult.localChange,
|
||||
|
@ -243,7 +243,7 @@ export class GlobalStateSynchroniser extends AbstractSynchroniser implements IUs
|
|||
override async resolveContent(uri: URI): Promise<string | null> {
|
||||
if (this.extUri.isEqual(uri, GlobalStateSynchroniser.GLOBAL_STATE_DATA_URI)) {
|
||||
const localGlobalState = await this.getLocalGlobalState();
|
||||
return stringify(localGlobalState);
|
||||
return stringify(localGlobalState, true);
|
||||
}
|
||||
|
||||
if (this.extUri.isEqual(this.remoteResource, uri) || this.extUri.isEqual(this.localResource, uri) || this.extUri.isEqual(this.acceptedResource, uri)) {
|
||||
|
@ -261,7 +261,7 @@ export class GlobalStateSynchroniser extends AbstractSynchroniser implements IUs
|
|||
if (syncData) {
|
||||
switch (this.extUri.basename(uri)) {
|
||||
case 'globalState.json':
|
||||
return stringify(JSON.parse(syncData.content));
|
||||
return stringify(JSON.parse(syncData.content), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ export class UserDataSyncStoreTypeSynchronizer {
|
|||
|
||||
// Write the global state to remote
|
||||
const machineId = await getServiceMachineId(this.environmentService, this.fileService, this.storageService);
|
||||
const syncDataToUpdate: ISyncData = { version: GLOBAL_STATE_DATA_VERSION, machineId, content: stringify(remoteGlobalState) };
|
||||
const syncDataToUpdate: ISyncData = { version: GLOBAL_STATE_DATA_VERSION, machineId, content: stringify(remoteGlobalState, false) };
|
||||
await this.userDataSyncStoreClient.write(SyncResource.GlobalState, JSON.stringify(syncDataToUpdate), globalStateUserData.ref, syncHeaders);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue