Skip to content

Commit

Permalink
revert copy settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Himanshu-Singh-Chauhan committed Jan 28, 2025
1 parent f3d102f commit ac466af
Showing 1 changed file with 5 additions and 33 deletions.
38 changes: 5 additions & 33 deletions extensions/vscode/src/copySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,8 @@ async function copyVSCodeSettingsToPearAIDir() {
await fs.promises.mkdir(pearAIDevSettingsDir, { recursive: true });
await fs.promises.mkdir(pearAIDevExtensionsDir, { recursive: true });

const itemsToCopy = ['settings.json', 'keybindings.json', 'snippets', 'sync', 'globalStorage/state.vscdb', 'globalStorage/state.vscdb.backup'];

// Special handling for copying settings.json to filter out layout settings
const settingsSource = path.join(vscodeSettingsDir, 'settings.json');
const settingsDestination = path.join(pearAIDevSettingsDir, 'settings.json');
try {
if (await fs.promises.access(settingsSource).then(() => true).catch(() => false)) {
const settingsContent = await fs.promises.readFile(settingsSource, 'utf8');
const settings = JSON.parse(settingsContent);

// Filter out layout-related settings
const filteredSettings = Object.fromEntries(
Object.entries(settings).filter(([key]) => !key.includes('workbench.') && !key.includes('window.'))
);

await fs.promises.writeFile(
settingsDestination,
JSON.stringify(filteredSettings, null, 2)
);
}
} catch (error) {
console.error(`Error copying settings.json: ${error}`);
}


const itemsToCopy = ['snippets', 'keybindings.json', 'sync', 'globalStorage/state.vscdb', 'globalStorage/state.vscdb.backup'];

for (const item of itemsToCopy) {
const source = path.join(vscodeSettingsDir, item);
const destination = path.join(pearAIDevSettingsDir, item);
Expand Down Expand Up @@ -167,14 +143,10 @@ export async function importUserSettingsFromVSCode() {
vscode.window.showInformationMessage('Copying your current VSCode settings and extensions over to PearAI!');
await copyVSCodeSettingsToPearAIDir();

const result = await vscode.window.showInformationMessage(
'Your VSCode settings and extensions have been transferred over to PearAI! Please restart extension host to activate imported extensions.',
'Ok', 'Restart Extension Host'
vscode.window.showInformationMessage(
'Your VSCode settings and extensions have been transferred over to PearAI! You may need to restart your editor for the changes to take effect.',
'Ok'
);

if (result === 'Restart Extension Host') {
vscode.commands.executeCommand('workbench.action.restartExtensionHost');
}
} catch (error) {
vscode.window.showErrorMessage(`Failed to copy settings: ${error}`);
}
Expand All @@ -194,4 +166,4 @@ export async function markCreatorOnboardingCompleteFileBased() {
} catch (error) {
console.error('Error marking creator onboarding complete:', error);
}
}
}

0 comments on commit ac466af

Please sign in to comment.