Skip to content

Commit 77323c8

Browse files
authored
1 parent 2f28a09 commit 77323c8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/vs/workbench/contrib/userDataProfile/browser/userDataProfilesEditorModel.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
3535
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
3636
import { CONFIG_NEW_WINDOW_PROFILE } from 'vs/workbench/common/configuration';
3737
import { ResourceMap } from 'vs/base/common/map';
38+
import { getErrorMessage } from 'vs/base/common/errors';
3839

3940
export type ChangeEvent = {
4041
readonly name?: boolean;
@@ -841,6 +842,16 @@ export class UserDataProfilesEditorModel extends EditorModel {
841842
}
842843
this.revert();
843844
}
845+
846+
if (copyFrom instanceof URI) {
847+
try {
848+
await this.userDataProfileImportExportService.resolveProfileTemplate(copyFrom);
849+
} catch (error) {
850+
this.dialogService.error(getErrorMessage(error));
851+
return;
852+
}
853+
}
854+
844855
if (!this.newProfileElement) {
845856
const disposables = new DisposableStore();
846857
const cancellationTokenSource = new CancellationTokenSource();

src/vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,16 @@ export class UserDataProfileImportExportService extends Disposable implements IU
819819
return null;
820820
}
821821

822-
const profileTemplate: Mutable<IUserDataProfileTemplate> = JSON.parse(profileContent);
822+
let profileTemplate: Mutable<IUserDataProfileTemplate>;
823+
824+
try {
825+
profileTemplate = JSON.parse(profileContent);
826+
} catch (error) {
827+
throw new Error(localize('invalid profile content', "This profile is not valid."));
828+
}
829+
823830
if (!isUserDataProfileTemplate(profileTemplate)) {
824-
throw new Error('Invalid profile content.');
831+
throw new Error(localize('invalid profile content', "This profile is not valid."));
825832
}
826833

827834
if (options?.name) {

0 commit comments

Comments
 (0)