diff --git a/src/sql/platform/connection/common/connectionConfig.ts b/src/sql/platform/connection/common/connectionConfig.ts index 0455ea2801..5c0d6843ca 100644 --- a/src/sql/platform/connection/common/connectionConfig.ts +++ b/src/sql/platform/connection/common/connectionConfig.ts @@ -13,6 +13,7 @@ import { generateUuid } from 'vs/base/common/uuid'; import * as nls from 'vs/nls'; import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { find, firstIndex } from 'vs/base/common/arrays'; +import { deepClone } from 'vs/base/common/objects'; const GROUPS_CONFIG_KEY = 'datasource.connectionGroups'; const CONNECTIONS_CONFIG_KEY = 'datasource.connections'; @@ -49,7 +50,7 @@ export class ConnectionConfig { } allGroups = allGroups.concat(userValue); } - return allGroups.map(g => { + return deepClone(allGroups).map(g => { if (g.parentId === '' || !g.parentId) { g.parentId = undefined; } @@ -63,7 +64,7 @@ export class ConnectionConfig { public addConnection(profile: IConnectionProfile): Promise { if (profile.saveProfile) { return this.addGroupFromProfile(profile).then(groupId => { - let profiles = this.configurationService.inspect(CONNECTIONS_CONFIG_KEY).userValue; + let profiles = deepClone(this.configurationService.inspect(CONNECTIONS_CONFIG_KEY).userValue); if (!profiles) { profiles = []; } @@ -108,7 +109,7 @@ export class ConnectionConfig { if (profile.groupId && profile.groupId !== Utils.defaultGroupId) { return Promise.resolve(profile.groupId); } else { - let groups = this.configurationService.inspect(GROUPS_CONFIG_KEY).userValue; + let groups = deepClone(this.configurationService.inspect(GROUPS_CONFIG_KEY).userValue); let result = this.saveGroup(groups!, profile.groupFullName, undefined, undefined); groups = result.groups; @@ -123,7 +124,7 @@ export class ConnectionConfig { if (profileGroup.id) { return Promise.resolve(profileGroup.id); } else { - let groups = this.configurationService.inspect(GROUPS_CONFIG_KEY).userValue; + let groups = deepClone(this.configurationService.inspect(GROUPS_CONFIG_KEY).userValue); let sameNameGroup = groups ? find(groups, group => group.name === profileGroup.name) : undefined; if (sameNameGroup) { let errMessage: string = nls.localize('invalidServerName', "A server group with the same name already exists."); @@ -148,7 +149,7 @@ export class ConnectionConfig { fromConfig = configs.workspaceValue || []; } if (fromConfig) { - profiles = fromConfig; + profiles = deepClone(fromConfig); if (this.fixConnectionIds(profiles)) { this.configurationService.updateValue(CONNECTIONS_CONFIG_KEY, profiles, configTarget); } @@ -262,7 +263,7 @@ export class ConnectionConfig { * Moves the source group under the target group. */ public changeGroupIdForConnectionGroup(source: ConnectionProfileGroup, target: ConnectionProfileGroup): Promise { - let groups = this.configurationService.inspect(GROUPS_CONFIG_KEY).userValue; + let groups = deepClone(this.configurationService.inspect(GROUPS_CONFIG_KEY).userValue); groups = groups!.map(g => { if (g.id === source.id) { g.parentId = target.id; @@ -286,8 +287,8 @@ export class ConnectionConfig { * Moves the connection under the target group with the new ID. */ private changeGroupIdForConnectionInSettings(profile: ConnectionProfile, newGroupID: string, target: ConfigurationTarget = ConfigurationTarget.USER): Promise { - let profiles = target === ConfigurationTarget.USER ? this.configurationService.inspect(CONNECTIONS_CONFIG_KEY).userValue : - this.configurationService.inspect(CONNECTIONS_CONFIG_KEY).workspaceValue; + let profiles = deepClone(target === ConfigurationTarget.USER ? this.configurationService.inspect(CONNECTIONS_CONFIG_KEY).userValue : + this.configurationService.inspect(CONNECTIONS_CONFIG_KEY).workspaceValue); if (profiles) { if (profile.parent && profile.parent.id === UNSAVED_GROUP_ID) { profile.groupId = newGroupID; @@ -328,7 +329,7 @@ export class ConnectionConfig { } public editGroup(source: ConnectionProfileGroup): Promise { - let groups = this.configurationService.inspect(GROUPS_CONFIG_KEY).userValue; + let groups = deepClone(this.configurationService.inspect(GROUPS_CONFIG_KEY).userValue); let sameNameGroup = groups ? find(groups, group => group.name === source.name && group.id !== source.id) : undefined; if (sameNameGroup) { let errMessage: string = nls.localize('invalidServerName', "A server group with the same name already exists."); diff --git a/src/sql/workbench/services/connection/browser/connectionDialogService.ts b/src/sql/workbench/services/connection/browser/connectionDialogService.ts index e2019c7c7a..15d3711e3f 100644 --- a/src/sql/workbench/services/connection/browser/connectionDialogService.ts +++ b/src/sql/workbench/services/connection/browser/connectionDialogService.ts @@ -489,6 +489,7 @@ export class ConnectionDialogService implements IConnectionDialogService { })); } + this._logService.error(message); this._errorMessageService.showDialog(severity, headerTitle, message, messageDetails, actions); } } diff --git a/src/vs/platform/configuration/common/configurationModels.ts b/src/vs/platform/configuration/common/configurationModels.ts index 80e8588b26..5b76411290 100644 --- a/src/vs/platform/configuration/common/configurationModels.ts +++ b/src/vs/platform/configuration/common/configurationModels.ts @@ -122,8 +122,7 @@ export class ConfigurationModel implements IConfigurationModel { } freeze(): ConfigurationModel { - // {{SQL CARBON EDIT}} @todo anthonydresser 4/12/19 needs investigation; we shouldn't need to do this - // this.isFrozen = true; + this.isFrozen = true; return this; }