Skip to content

Commit

Permalink
💄
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Sep 3, 2019
1 parent e374f33 commit dfeeb51
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions src/vs/workbench/contrib/scm/browser/scmViewlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1072,37 +1072,6 @@ export class SCMViewlet extends ViewContainerViewlet implements IViewModel {
return Event.map(modificationEvent, () => this.visibleRepositories);
}

setVisibleRepositories(repositories: ISCMRepository[]): void {
const visibleViewDescriptors = this.viewsModel.visibleViewDescriptors;

const toSetVisible = this.viewsModel.viewDescriptors
.filter((d): d is RepositoryViewDescriptor => d instanceof RepositoryViewDescriptor && repositories.indexOf(d.repository) > -1 && visibleViewDescriptors.indexOf(d) === -1);

const toSetInvisible = visibleViewDescriptors
.filter((d): d is RepositoryViewDescriptor => d instanceof RepositoryViewDescriptor && repositories.indexOf(d.repository) === -1);

let size: number | undefined;
const oneToOne = toSetVisible.length === 1 && toSetInvisible.length === 1;

for (const viewDescriptor of toSetInvisible) {
if (oneToOne) {
const panel = this.panels.filter(panel => panel.id === viewDescriptor.id)[0];

if (panel) {
size = this.getPanelSize(panel);
}
}

viewDescriptor.repository.setSelected(false);
this.viewsModel.setVisible(viewDescriptor.id, false);
}

for (const viewDescriptor of toSetVisible) {
viewDescriptor.repository.setSelected(true);
this.viewsModel.setVisible(viewDescriptor.id, true, size);
}
}

constructor(
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
@ITelemetryService telemetryService: ITelemetryService,
Expand Down Expand Up @@ -1263,4 +1232,35 @@ export class SCMViewlet extends ViewContainerViewlet implements IViewModel {
return this.repositories[0].provider;
}
}

setVisibleRepositories(repositories: ISCMRepository[]): void {
const visibleViewDescriptors = this.viewsModel.visibleViewDescriptors;

const toSetVisible = this.viewsModel.viewDescriptors
.filter((d): d is RepositoryViewDescriptor => d instanceof RepositoryViewDescriptor && repositories.indexOf(d.repository) > -1 && visibleViewDescriptors.indexOf(d) === -1);

const toSetInvisible = visibleViewDescriptors
.filter((d): d is RepositoryViewDescriptor => d instanceof RepositoryViewDescriptor && repositories.indexOf(d.repository) === -1);

let size: number | undefined;
const oneToOne = toSetVisible.length === 1 && toSetInvisible.length === 1;

for (const viewDescriptor of toSetInvisible) {
if (oneToOne) {
const panel = this.panels.filter(panel => panel.id === viewDescriptor.id)[0];

if (panel) {
size = this.getPanelSize(panel);
}
}

viewDescriptor.repository.setSelected(false);
this.viewsModel.setVisible(viewDescriptor.id, false);
}

for (const viewDescriptor of toSetVisible) {
viewDescriptor.repository.setSelected(true);
this.viewsModel.setVisible(viewDescriptor.id, true, size);
}
}
}

0 comments on commit dfeeb51

Please sign in to comment.