mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
fixes #33615
This commit is contained in:
@@ -47,9 +47,39 @@ export class Model {
|
||||
|
||||
private possibleGitRepositoryPaths = new Set<string>();
|
||||
|
||||
private enabled = false;
|
||||
private configurationChangeDisposable: Disposable;
|
||||
private disposables: Disposable[] = [];
|
||||
|
||||
constructor(private git: Git) {
|
||||
const config = workspace.getConfiguration('git');
|
||||
this.enabled = config.get<boolean>('enabled') === true;
|
||||
|
||||
this.configurationChangeDisposable = workspace.onDidChangeConfiguration(this.onDidChangeConfiguration, this);
|
||||
|
||||
if (this.enabled) {
|
||||
this.enable();
|
||||
}
|
||||
}
|
||||
|
||||
private onDidChangeConfiguration(): void {
|
||||
const config = workspace.getConfiguration('git');
|
||||
const enabled = config.get<boolean>('enabled') === true;
|
||||
|
||||
if (enabled === this.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.enabled = enabled;
|
||||
|
||||
if (enabled) {
|
||||
this.enable();
|
||||
} else {
|
||||
this.disable();
|
||||
}
|
||||
}
|
||||
|
||||
private enable(): void {
|
||||
workspace.onDidChangeWorkspaceFolders(this.onDidChangeWorkspaceFolders, this, this.disposables);
|
||||
this.onDidChangeWorkspaceFolders({ added: workspace.workspaceFolders || [], removed: [] });
|
||||
|
||||
@@ -67,6 +97,15 @@ export class Model {
|
||||
this.scanWorkspaceFolders();
|
||||
}
|
||||
|
||||
private disable(): void {
|
||||
const openRepositories = [...this.openRepositories];
|
||||
openRepositories.forEach(r => r.dispose());
|
||||
this.openRepositories = [];
|
||||
|
||||
this.possibleGitRepositoryPaths.clear();
|
||||
this.disposables = dispose(this.disposables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans the first level of each workspace folder, looking
|
||||
* for git repositories.
|
||||
@@ -94,7 +133,7 @@ export class Model {
|
||||
this.tryOpenRepository(path);
|
||||
}
|
||||
|
||||
this.possibleGitRepositoryPaths = new Set<string>();
|
||||
this.possibleGitRepositoryPaths.clear();
|
||||
}
|
||||
|
||||
private async onDidChangeWorkspaceFolders({ added, removed }: WorkspaceFoldersChangeEvent): Promise<void> {
|
||||
@@ -246,7 +285,7 @@ export class Model {
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
[...this.openRepositories].forEach(r => r.dispose());
|
||||
this.disposables = dispose(this.disposables);
|
||||
this.disable();
|
||||
this.configurationChangeDisposable.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user