(nodesById: Map<string, TreeNodeData>, ids: string[])
| 89 | } |
| 90 | |
| 91 | function sortIdsByNode(nodesById: Map<string, TreeNodeData>, ids: string[]): string[] { |
| 92 | return [...ids].sort((leftId, rightId) => { |
| 93 | const left = nodesById.get(leftId); |
| 94 | const right = nodesById.get(rightId); |
| 95 | const leftDir = left?.isDirectory ? 0 : 1; |
| 96 | const rightDir = right?.isDirectory ? 0 : 1; |
| 97 | if (leftDir !== rightDir) { |
| 98 | return leftDir - rightDir; |
| 99 | } |
| 100 | const leftLabel = normalizeLabel(left ?? { id: leftId, isDirectory: false }).toLocaleLowerCase(); |
| 101 | const rightLabel = normalizeLabel(right ?? { id: rightId, isDirectory: false }).toLocaleLowerCase(); |
| 102 | if (leftLabel !== rightLabel) { |
| 103 | return leftLabel.localeCompare(rightLabel); |
| 104 | } |
| 105 | return leftId.localeCompare(rightId); |
| 106 | }); |
| 107 | } |
| 108 | |
| 109 | export function buildVisibleRows( |
| 110 | nodesById: Map<string, TreeNodeData>, |
no test coverage detected