Skip to content

Commit

Permalink
Merge pull request #280 from lorentey/minor-rope-updates
Browse files Browse the repository at this point in the history
[Rope] remove(at:): Fix assertion when removing the last item creates a deficiency
  • Loading branch information
lorentey authored Apr 18, 2023
2 parents 9bb319f + dce7b15 commit 2ca40e2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/RopeModule/Rope/Operations/Rope+Remove.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 2ca40e2

Please sign in to comment.