Merge c5a10aa065
into 7dfcd74e63
This commit is contained in:
commit
52f8ba1ba2
|
@ -83,7 +83,7 @@ export class RepositoryRenderer implements ICompressibleTreeRenderer<ISCMReposit
|
|||
if (folder?.uri.toString() === repository.provider.rootUri.toString()) {
|
||||
templateData.name.textContent = folder.name;
|
||||
} else {
|
||||
templateData.name.textContent = basename(repository.provider.rootUri);
|
||||
templateData.name.textContent = (folder ? '┡ ' : '') + basename(repository.provider.rootUri);
|
||||
}
|
||||
|
||||
templateData.label.title = `${repository.provider.label}: ${repository.provider.rootUri.fsPath}`;
|
||||
|
|
|
@ -21,6 +21,12 @@ export interface ISCMViewServiceState {
|
|||
readonly visible: number[];
|
||||
}
|
||||
|
||||
interface SortIndex {
|
||||
index: number;
|
||||
uri: string;
|
||||
children: SortIndex[];
|
||||
}
|
||||
|
||||
export class SCMViewService implements ISCMViewService {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
@ -60,7 +66,7 @@ export class SCMViewService implements ISCMViewService {
|
|||
return;
|
||||
}
|
||||
|
||||
this._visibleRepositories = visibleRepositories;
|
||||
this._visibleRepositories = this.sortRepositories(visibleRepositories);
|
||||
this._visibleRepositoriesSet = set;
|
||||
this._onDidSetVisibleRepositories.fire({ added, removed });
|
||||
|
||||
|
@ -120,6 +126,33 @@ export class SCMViewService implements ISCMViewService {
|
|||
storageService.onWillSaveState(this.onWillSaveState, this, this.disposables);
|
||||
}
|
||||
|
||||
private sortRepositories(visibleRepositories: ISCMRepository[]): ISCMRepository[] {
|
||||
let sortIndexs: SortIndex[] = visibleRepositories.map((repo, index) => ({
|
||||
index,
|
||||
uri: repo.provider.rootUri!.path,
|
||||
children: []
|
||||
}));
|
||||
sortIndexs.sort((a, b) => b.uri.length - a.uri.length);
|
||||
for (let i = sortIndexs.length; i--;) {
|
||||
const repo = sortIndexs[i];
|
||||
const rootUri = `${repo.uri}/`;
|
||||
|
||||
for (let j = i; j--;) {
|
||||
if (sortIndexs[j].uri.includes(rootUri)) {
|
||||
repo.children = sortIndexs.splice(j, 1).concat(repo.children);
|
||||
--i;
|
||||
}
|
||||
}
|
||||
}
|
||||
sortIndexs.sort((a, b) => a.index - b.index);
|
||||
sortIndexs = sortIndexs.reduce((acc: SortIndex[], repo) => {
|
||||
acc.push(repo, ...repo.children);
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
return sortIndexs.map(({ index }) => visibleRepositories[index]);
|
||||
}
|
||||
|
||||
private onDidAddRepository(repository: ISCMRepository): void {
|
||||
if (!this.didFinishLoading) {
|
||||
this.eventuallyFinishLoading();
|
||||
|
@ -164,6 +197,7 @@ export class SCMViewService implements ISCMViewService {
|
|||
}
|
||||
|
||||
this._visibleRepositories.push(repository);
|
||||
this._visibleRepositories = this.sortRepositories(this._visibleRepositories);
|
||||
this._visibleRepositoriesSet.add(repository);
|
||||
this._onDidChangeRepositories.fire({ added: [repository], removed });
|
||||
|
||||
|
|
Loading…
Reference in a new issue