1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-10-27 10:23:12 +03:00

GH-389 Fix common parent computation

This commit is contained in:
Tae Won Ha 2017-04-18 19:55:24 +02:00
parent fdf67b6fc7
commit 55cccc92ff
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
2 changed files with 4 additions and 4 deletions

View File

@ -51,7 +51,7 @@ class FileUtils {
return URL(fileURLWithPath: "/", isDirectory: true)
}
let pathComps = urls.map { $0.pathComponents }
let pathComps = urls.map { $0.deletingLastPathComponent().pathComponents }
let min = pathComps.map { $0.count }.min()!
let pathCompsOnlyMin = pathComps.map { $0[0..<min] }
let commonIdx = (0..<min).reversed().reduce(min - 1) { (result, idx) in

View File

@ -22,7 +22,7 @@ class FileUtilsTest: XCTestCase {
fileUtilsRsrcUrl.appendingPathComponent("a1"),
]
expect(FileUtils.commonParent(of: urls)).to(equal(a1Dir))
expect(FileUtils.commonParent(of: urls)).to(equal(fileUtilsRsrcUrl))
}
func testCommonParentOneFileUrl() {
@ -43,7 +43,7 @@ class FileUtilsTest: XCTestCase {
fileUtilsRsrcUrl.appendingPathComponent("a1/a1-file1"),
]
expect(FileUtils.commonParent(of: urls)).to(equal(a1Dir))
expect(FileUtils.commonParent(of: urls)).to(equal(fileUtilsRsrcUrl))
}
func testCommonParent2() {
@ -53,7 +53,7 @@ class FileUtilsTest: XCTestCase {
fileUtilsRsrcUrl.appendingPathComponent("a1/a2/a1-a2-file1"),
]
expect(FileUtils.commonParent(of: urls)).to(equal(a1Dir))
expect(FileUtils.commonParent(of: urls)).to(equal(fileUtilsRsrcUrl))
}
func testBug1() {