Merge pull request #280 from lorentey/minor-rope-updates

[Rope] remove(at:): Fix assertion when removing the last item creates a deficiency
This commit is contained in:
Karoy Lorentey authored and GitHub committed 2023-04-17 17:29:18 -07:00
commit 2ca40e2a65
1 file changed
+4 -4
@@ -64,10 +64,10 @@ extension Rope._Node {
let prepended = fixDeficiency(on: &path)
isAtEnd = isAtEnd && prepended
}
if isAtEnd {
if isAtEnd, path[h] < childCount - 1 {
path[h] += 1
path.clear(below: h)
isAtEnd = path[h] == childCount
isAtEnd = false
}
return (r.removed, r.delta, self.isUndersized, isAtEnd)
}
@@ -134,10 +134,10 @@ extension Rope._Node {
let prepended = fixDeficiency(on: &path)
isAtEnd = isAtEnd && prepended
}
if isAtEnd {
if isAtEnd, path[h] < childCount - 1 {
path[h] += 1
path.clear(below: h)
isAtEnd = path[h] == childCount
isAtEnd = false
}
return (r.removed, r.delta, self.isUndersized, isAtEnd)
}