fix another buggy Vector.tabulate case

This commit is contained in:
2024-07-03 14:05:27 +01:00
parent 65b3db2a6a
commit 5117678c1d
3 changed files with 33 additions and 21 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -814,37 +814,49 @@ struct
(Vector.length rightLinesHd - midpoint) + Vector.length newLines (Vector.length rightLinesHd - midpoint) + Vector.length newLines
<= vecLimit <= vecLimit
*) *)
false true
then then
(* If we can join newString/line with sub2 while staying (* If we can join newString/line with sub2 while staying
* in limit. *) * in limit. *)
let let
(* VERIFIED TO WORK *)
val _ = print "line 581\n" val _ = print "line 581\n"
val newRightStringsHd = newString ^ strSub2 val newLeftLinesHd =
(* if midpoint >= 0 then
val newRightLinesHd = let
Vector.tabulate val newLeftLinesHd = VectorSlice.slice
( Vector.length newLines + Vector.length rightLinesHd - midpoint (rightLinesHd, 0, SOME (midpoint + 1))
, fn idx => in
if idx < Vector.length newLines then VectorSlice.vector newLeftLinesHd
Vector.sub (newLines, idx) end
else else
Vector.sub (rightLinesHd, idx - Vector.length newLines) Vector.fromList []
+ String.size newString
) val newRightStringsHd = newString ^ strSub2
val newRightLinesHd =
Vector.tabulate
( (Vector.length newLines + Vector.length rightLinesHd)
- Vector.length newLeftLinesHd
, fn idx =>
if idx < Vector.length newLines then
Vector.sub (newLines, idx)
else
(Vector.sub
( rightLinesHd
, (idx - Vector.length newLines)
+ Vector.length newLeftLinesHd
) - String.size strSub1) + String.size newString
)
val newLeftLinesHd =
VectorSlice.slice (rightLinesHd, 0, SOME midpoint)
val newLeftLinesHd = VectorSlice.vector newLeftLinesHd
*)
in in
verifyReturn verifyReturn
{ idx = curIdx + String.size strSub1 { idx = curIdx + String.size strSub1
, line = curLine + Vector.length (countLineBreaks strSub1) , line = curLine + Vector.length newLeftLinesHd
, leftStrings = strSub1 :: leftStrings , leftStrings = strSub1 :: leftStrings
, leftLines = countLineBreaks strSub1 :: leftLines , leftLines = newLeftLinesHd :: leftLines
, rightStrings = newRightStringsHd :: rightStringsTl , rightStrings = newRightStringsHd :: rightStringsTl
, rightLines = countLineBreaks newRightStringsHd :: rightLinesTl , rightLines = newRightLinesHd :: rightLinesTl
} }
end end
else else
@@ -925,7 +937,7 @@ struct
Vector.sub Vector.sub
(rightLinesHd, idx - Vector.length leftLinesHd) (rightLinesHd, idx - Vector.length leftLinesHd)
+ String.size leftStringsHd + String.size leftStringsHd
) )
in in
moveRightAndIns moveRightAndIns
( idx ( idx