1
1
mirror of https://github.com/qvacua/vimr.git synced 2025-01-04 20:02:04 +03:00

display folders before files in file browser

This commit is contained in:
Guillaume Bailleul 2018-04-13 02:25:37 +02:00
parent 3be3e20463
commit 0f8fdee9ed

View File

@ -94,8 +94,18 @@ class FileOutlineView: NSOutlineView,
}
override func reloadData() {
let newCells = self.cells.sorted{
let i = $0
let j = $1
return true
}
self.cells.removeAll()
self.widths.removeAll()
super.reloadData()
}
@ -215,7 +225,13 @@ class FileOutlineView: NSOutlineView,
}
private func sortedChildren(of url: URL) -> [FileBrowserItem] {
return FileUtils.directDescendants(of: url).map(FileBrowserItem.init).sorted()
return FileUtils.directDescendants(of: url).map(FileBrowserItem.init).sorted{
if ($0.isDir == $1.isDir) {
return $0.url.absoluteString < $1.url.absoluteString
}
return $0.isDir
}
}
private func update(_ fileBrowserItem: FileBrowserItem) {
@ -344,7 +360,7 @@ extension FileOutlineView {
guard let fileBrowserItem = item as? FileBrowserItem else {
return false
}
return fileBrowserItem.url.isDir
}