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:
parent
fdf67b6fc7
commit
55cccc92ff
@ -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
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user