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 newLeftLinesHd =
if midpoint >= 0 then
let
val newLeftLinesHd = VectorSlice.slice
(rightLinesHd, 0, SOME (midpoint + 1))
in
VectorSlice.vector newLeftLinesHd
end
else
Vector.fromList []
val newRightStringsHd = newString ^ strSub2 val newRightStringsHd = newString ^ strSub2
(*
val newRightLinesHd = val newRightLinesHd =
Vector.tabulate Vector.tabulate
( Vector.length newLines + Vector.length rightLinesHd - midpoint ( (Vector.length newLines + Vector.length rightLinesHd)
- Vector.length newLeftLinesHd
, fn idx => , fn idx =>
if idx < Vector.length newLines then if idx < Vector.length newLines then
Vector.sub (newLines, idx) Vector.sub (newLines, idx)
else else
Vector.sub (rightLinesHd, idx - Vector.length newLines) (Vector.sub
+ String.size newString ( 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