Skip to content

Commit a1a1c57

Browse files
authored
bug: project initialization to load existing projects without overwriting user settings (#1202)
fixes #1200
1 parent 1e25bbb commit a1a1c57

File tree

3 files changed

+696
-2
lines changed

3 files changed

+696
-2
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ node_modules
55
*.vsix
66
.nox/
77
.venv/
8-
**/__pycache__/
8+
**/__pycache__/
9+
10+
# Folder for storing AI generated artifacts
11+
ai-artifacts/*

src/features/projectManager.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ export class PythonProjectManagerImpl implements PythonProjectManager {
3333
private readonly updateDebounce = createSimpleDebounce(100, () => this.updateProjects());
3434

3535
initialize(): void {
36-
this.add(this.getInitialProjects());
36+
// Load existing projects from settings without writing back to settings.
37+
// This avoids overwriting user-configured project settings with defaults on reload.
38+
this.loadProjects(this.getInitialProjects());
3739
this.disposables.push(
3840
this._onDidChangeProjects,
3941
new Disposable(() => this._projects.clear()),
@@ -175,6 +177,20 @@ export class PythonProjectManagerImpl implements PythonProjectManager {
175177
}
176178
}
177179

180+
/**
181+
* Loads projects into the internal map without writing to settings.
182+
* Use this for initial loading from existing settings to avoid overwriting
183+
* user-configured project settings with defaults.
184+
*/
185+
private loadProjects(projects: ProjectArray): void {
186+
projects.forEach((project) => {
187+
this._projects.set(project.uri.toString(), project);
188+
});
189+
if (projects.length > 0) {
190+
this._onDidChangeProjects.fire(Array.from(this._projects.values()));
191+
}
192+
}
193+
178194
create(
179195
name: string,
180196
uri: Uri,

0 commit comments

Comments
 (0)