浏览代码

Closes #547 - Adds natural sorting to branches, tags, and files

main
Eric Amodio 6 年前
父节点
当前提交
84f7ee93c6
共有 11 个文件被更改,包括 34 次插入21 次删除
  1. +6
    -2
      src/quickpicks/branchesAndTagsQuickPick.ts
  2. +3
    -1
      src/quickpicks/repoStatusQuickPick.ts
  3. +3
    -4
      src/views/nodes/branchesNode.ts
  4. +3
    -1
      src/views/nodes/commitNode.ts
  5. +1
    -1
      src/views/nodes/folderNode.ts
  6. +5
    -7
      src/views/nodes/remoteNode.ts
  7. +1
    -1
      src/views/nodes/remotesNode.ts
  8. +5
    -1
      src/views/nodes/resultsFilesNode.ts
  9. +1
    -1
      src/views/nodes/stashNode.ts
  10. +5
    -1
      src/views/nodes/statusFilesNode.ts
  11. +1
    -1
      src/views/nodes/tagsNode.ts

+ 6
- 2
src/quickpicks/branchesAndTagsQuickPick.ts 查看文件

@ -265,7 +265,11 @@ export class BranchesAndTagsQuickPick {
const filter =
filters !== undefined && typeof filters.branches === 'function' ? filters.branches : undefined;
branches.sort((a, b) => (b.remote ? -1 : 1) - (a.remote ? -1 : 1) || a.name.localeCompare(b.name));
branches.sort(
(a, b) =>
(b.remote ? -1 : 1) - (a.remote ? -1 : 1) ||
a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' })
);
for (const b of branches) {
if (filter !== undefined && !filter(b)) continue;
@ -276,7 +280,7 @@ export class BranchesAndTagsQuickPick {
if (tags !== undefined) {
const filter = filters !== undefined && typeof filters.tags === 'function' ? filters.tags : undefined;
tags.sort((a, b) => a.name.localeCompare(b.name));
tags.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }));
for (const t of tags) {
if (filter !== undefined && !filter(t)) continue;

+ 3
- 1
src/quickpicks/repoStatusQuickPick.ts 查看文件

@ -224,7 +224,9 @@ export class RepoStatusQuickPick {
((a as OpenStatusFileCommandQuickPickItem).status.staged ? -1 : 1) -
((b as OpenStatusFileCommandQuickPickItem).status.staged ? -1 : 1) ||
(a as OpenStatusFileCommandQuickPickItem).status.fileName.localeCompare(
(b as OpenStatusFileCommandQuickPickItem).status.fileName
(b as OpenStatusFileCommandQuickPickItem).status.fileName,
undefined,
{ numeric: true, sensitivity: 'base' }
)
);

+ 3
- 4
src/views/nodes/branchesNode.ts 查看文件

@ -30,13 +30,12 @@ export class BranchesNode extends ViewNode {
const branches = await this.repo.getBranches();
if (branches === undefined) return [];
branches.sort((a, b) => a.name.localeCompare(b.name));
branches.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }));
// filter local branches
const branchNodes = [
...Iterables.filterMap(
branches,
b => (b.remote ? undefined : new BranchNode(this.uri, this.view, this, b))
...Iterables.filterMap(branches, b =>
b.remote ? undefined : new BranchNode(this.uri, this.view, this, b)
)
];
if (this.view.config.branches.layout === ViewBranchesLayout.List) return branchNodes;

+ 3
- 1
src/views/nodes/commitNode.ts 查看文件

@ -48,7 +48,9 @@ export class CommitNode extends ViewRefNode {
children = (await root.getChildren()) as FileNode[];
}
else {
children.sort((a, b) => a.label!.localeCompare(b.label!));
children.sort((a, b) =>
a.label!.localeCompare(b.label!, undefined, { numeric: true, sensitivity: 'base' })
);
}
return children;
}

+ 1
- 1
src/views/nodes/folderNode.ts 查看文件

@ -61,7 +61,7 @@ export class FolderNode extends ViewNode {
return (
(a instanceof FolderNode ? -1 : 1) - (b instanceof FolderNode ? -1 : 1) ||
a.priority - b.priority ||
a.label!.localeCompare(b.label!)
a.label!.localeCompare(b.label!, undefined, { numeric: true, sensitivity: 'base' })
);
});

+ 5
- 7
src/views/nodes/remoteNode.ts 查看文件

@ -29,16 +29,14 @@ export class RemoteNode extends ViewNode {
const branches = await this.repo.getBranches();
if (branches === undefined) return [];
branches.sort((a, b) => a.name.localeCompare(b.name));
branches.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }));
// filter remote branches
const branchNodes = [
...Iterables.filterMap(
branches,
b =>
!b.remote || !b.name.startsWith(this.remote.name)
? undefined
: new BranchNode(this.uri, this.view, this, b)
...Iterables.filterMap(branches, b =>
!b.remote || !b.name.startsWith(this.remote.name)
? undefined
: new BranchNode(this.uri, this.view, this, b)
)
];
if (this.view.config.branches.layout === ViewBranchesLayout.List) return branchNodes;

+ 1
- 1
src/views/nodes/remotesNode.ts 查看文件

@ -28,7 +28,7 @@ export class RemotesNode extends ViewNode {
return [new MessageNode(this.view, this, 'No remotes could be found')];
}
remotes.sort((a, b) => a.name.localeCompare(b.name));
remotes.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }));
return [...Iterables.map(remotes, r => new RemoteNode(this.uri, this.view, this, r, this.repo))];
}

+ 5
- 1
src/views/nodes/resultsFilesNode.ts 查看文件

@ -46,7 +46,11 @@ export class ResultsFilesNode extends ViewNode {
children = (await root.getChildren()) as FileNode[];
}
else {
children.sort((a, b) => a.priority - b.priority || a.label!.localeCompare(b.label!));
children.sort(
(a, b) =>
a.priority - b.priority ||
a.label!.localeCompare(b.label!, undefined, { numeric: true, sensitivity: 'base' })
);
}
return children;

+ 1
- 1
src/views/nodes/stashNode.ts 查看文件

@ -42,7 +42,7 @@ export class StashNode extends ViewRefNode {
}
const children = files.map(s => new StashFileNode(this.view, this, s, this.commit.toFileCommit(s)));
children.sort((a, b) => a.label!.localeCompare(b.label!));
children.sort((a, b) => a.label!.localeCompare(b.label!, undefined, { numeric: true, sensitivity: 'base' }));
return children;
}

+ 5
- 1
src/views/nodes/statusFilesNode.ts 查看文件

@ -102,7 +102,11 @@ export class StatusFilesNode extends ViewNode {
children = (await root.getChildren()) as FileNode[];
}
else {
children.sort((a, b) => a.priority - b.priority || a.label!.localeCompare(b.label!));
children.sort(
(a, b) =>
a.priority - b.priority ||
a.label!.localeCompare(b.label!, undefined, { numeric: true, sensitivity: 'base' })
);
}
return children;

+ 1
- 1
src/views/nodes/tagsNode.ts 查看文件

@ -28,7 +28,7 @@ export class TagsNode extends ViewNode {
const tags = await this.repo.getTags();
if (tags.length === 0) return [new MessageNode(this.view, this, 'No tags could be found.')];
tags.sort((a, b) => a.name.localeCompare(b.name));
tags.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }));
const tagNodes = tags.map(t => new TagNode(this.uri, this.view, this, t));
if (this.view.config.branches.layout === ViewBranchesLayout.List) return tagNodes;

正在加载...
取消
保存