提交 8396f97c 编写于 作者: E Emily Marigold Klassen

Add a rootIndex property to FileStat to ensure sorting roots is stable

上级 58292626
......@@ -569,6 +569,9 @@ export class FileSorter implements ISorter {
public compare(tree: ITree, statA: FileStat, statB: FileStat): number {
// Do not sort roots
if (statA.isRoot && statB.isRoot) {
return statA.rootIndex - statB.rootIndex;
}
if (statA.isRoot) {
return -1;
}
......
......@@ -25,7 +25,7 @@ export class Model {
private _roots: FileStat[];
constructor( @IWorkspaceContextService private contextService: IWorkspaceContextService) {
const setRoots = () => this._roots = this.contextService.getWorkspace().roots.map(uri => new FileStat(uri, undefined));
const setRoots = () => this._roots = this.contextService.getWorkspace().roots.map((uri, index) => new FileStat(uri, undefined, undefined, undefined, undefined, undefined, undefined, index));
this.contextService.onDidChangeWorkspaceRoots(() => setRoots());
setRoots();
}
......@@ -74,7 +74,7 @@ export class FileStat implements IFileStat {
public exists: boolean;
public isDirectoryResolved: boolean;
constructor(resource: URI, public root: FileStat, isDirectory?: boolean, hasChildren?: boolean, name: string = paths.basename(resource.fsPath), mtime?: number, etag?: string) {
constructor(resource: URI, public root: FileStat, isDirectory?: boolean, hasChildren?: boolean, name: string = paths.basename(resource.fsPath), mtime?: number, etag?: string, public rootIndex?: number) {
this.resource = resource;
this.name = name;
this.isDirectory = !!isDirectory;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册