Skip to content

Commit a5de710

Browse files
committed
feat: sort keys
1 parent 2f99d63 commit a5de710

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/core/LocaleLoader.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { MachinTranslate } from './MachineTranslate'
88
import { getKeyname, getFileInfo, replaceLocalePath, notEmpty } from './utils'
99
import { LocaleTree, ParsedFile, FlattenLocaleTree, Coverage, LocaleNode, LocaleRecord, PendingWrite } from './types'
1010
import { AllyError, ErrorType } from './Errors'
11-
import { load } from 'js-yaml'
1211

1312
function newTree (keypath = '', values = {}): LocaleTree {
1413
return {

src/views/FileLocalesTreeView.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ export class FileLocalesTreeProvider extends LocalesTreeProvider {
4444
roots.push(this.newItem(node))
4545
}
4646

47-
sortBy(roots, 'keypath')
48-
49-
return roots
47+
return sortBy(roots, 'node.keypath')
5048
}
5149
}
5250

src/views/LocalesTreeView.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Global, LocaleLoader, LocaleNode, LocaleRecord, LocaleTree, decorateLocale } from '../core'
22
import { ExtensionModule } from '../modules'
33
import { TreeItem, ExtensionContext, TreeItemCollapsibleState, TreeDataProvider, EventEmitter, Event, window } from 'vscode'
4+
import { sortBy } from 'lodash'
45

56
export type Node = LocaleNode | LocaleRecord | LocaleTree
67

@@ -136,9 +137,11 @@ export class LocalesTreeProvider implements TreeDataProvider<LocaleTreeItem> {
136137
? Object.values(this.loader.flattenLocaleTree)
137138
: Object.values(this.loader.localeTree.children)
138139

139-
return nodes
140+
const items = nodes
140141
.filter(node => this.filter(node))
141142
.map(node => this.newItem(node))
143+
144+
return sortBy(items, 'node.keypath')
142145
}
143146

144147
async getChildren (element?: LocaleTreeItem) {
@@ -153,9 +156,11 @@ export class LocalesTreeProvider implements TreeDataProvider<LocaleTreeItem> {
153156
else if (element.node.type === 'node')
154157
nodes = Object.values(this.loader.getShadowLocales(element.node))
155158

156-
return nodes
159+
const items = nodes
157160
.filter(node => this.filter(node))
158161
.map(r => this.newItem(r))
162+
163+
return sortBy(items, 'node.keypath')
159164
}
160165
}
161166

0 commit comments

Comments
 (0)