fix another vector joining case
This commit is contained in:
@@ -370,7 +370,8 @@ struct
|
|||||||
in
|
in
|
||||||
if
|
if
|
||||||
(* isThreeInLimit (strSub1, newString, strSub2, leftLinesHd, newLines)
|
(* isThreeInLimit (strSub1, newString, strSub2, leftLinesHd, newLines)
|
||||||
* *) false
|
* *)
|
||||||
|
false
|
||||||
then
|
then
|
||||||
(* Join three strings together. *)
|
(* Join three strings together. *)
|
||||||
let
|
let
|
||||||
@@ -404,7 +405,7 @@ struct
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
else if
|
else if
|
||||||
true (*
|
false (*
|
||||||
String.size strSub1 + String.size newString <= stringLimit
|
String.size strSub1 + String.size newString <= stringLimit
|
||||||
andalso midpoint + Vector.length newLines <= vecLimit
|
andalso midpoint + Vector.length newLines <= vecLimit
|
||||||
*)
|
*)
|
||||||
@@ -412,25 +413,53 @@ struct
|
|||||||
(* If we can join newString/lines with sub1 while
|
(* If we can join newString/lines with sub1 while
|
||||||
* staying in limit. *)
|
* staying in limit. *)
|
||||||
let
|
let
|
||||||
val _ = print "line 268\n"
|
val _ = print "line 416\n\n\n"
|
||||||
val _ = print
|
val _ = print
|
||||||
("vector length: " ^ Int.toString (Vector.length newLines) ^ "\n")
|
("vector length: " ^ Int.toString (Vector.length newLines) ^ "\n")
|
||||||
val _ = print ("midpoint: " ^ Int.toString (midpoint) ^ "\n")
|
val _ = print ("midpoint: " ^ Int.toString (midpoint) ^ "\n")
|
||||||
|
val _ = print ("leftLinesHd: " ^ lineBreaksToString leftLinesHd)
|
||||||
|
|
||||||
val newLeftLines = countLineBreaks (strSub1 ^ newString)
|
(* NEWLEFTLINES VERIFIED *)
|
||||||
(*
|
|
||||||
val newLeftLines =
|
val newLeftLines =
|
||||||
Vector.tabulate (midpoint + Vector.length newLines, fn idx =>
|
if Vector.length leftLinesHd = 0 then
|
||||||
if idx < midpoint then Vector.sub (leftLinesHd, idx)
|
Vector.map (fn el => el + String.size strSub1) newLines
|
||||||
else Vector.sub (newLines, idx - midpoint) + String.size strSub1)
|
else
|
||||||
*)
|
let
|
||||||
|
val newLeftLinesLength = midpoint + 1 + Vector.length newLines
|
||||||
|
in
|
||||||
|
if newLeftLinesLength >= 0 then
|
||||||
|
Vector.tabulate (newLeftLinesLength, fn idx =>
|
||||||
|
if idx <= midpoint then
|
||||||
|
Vector.sub (leftLinesHd, idx)
|
||||||
|
else
|
||||||
|
Vector.sub (newLines, idx - (midpoint + 1))
|
||||||
|
+ String.size strSub1)
|
||||||
|
else
|
||||||
|
Vector.fromList []
|
||||||
|
end
|
||||||
|
|
||||||
val _ = print "line 275\n"
|
val _ = print "line 275\n"
|
||||||
|
|
||||||
(*
|
(* NEWRIGHTLINES VERIFIED *)
|
||||||
val newRightLines = VectorSlice.slice (leftLinesHd, midpoint, SOME
|
val newRightLines =
|
||||||
(Vector.length leftLinesHd - midpoint))
|
if Vector.length leftLinesHd = 0 then
|
||||||
val newRightLines = VectorSlice.vector newRightLines
|
Vector.fromList []
|
||||||
*)
|
else if midpoint >= 0 then
|
||||||
|
let
|
||||||
|
val _ = print "line 447\n"
|
||||||
|
in
|
||||||
|
Vector.tabulate
|
||||||
|
( (Vector.length leftLinesHd - midpoint) - 1
|
||||||
|
, fn idx =>
|
||||||
|
Vector.sub (leftLinesHd, idx + midpoint + 1)
|
||||||
|
- String.size strSub1
|
||||||
|
)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
(* midpoint = ~1 andalso Vector.length leftLinesHd > 0 *)
|
||||||
|
let val _ = print "line 458\n"
|
||||||
|
in Vector.map (fn idx => idx - String.size strSub1) leftLinesHd
|
||||||
|
end
|
||||||
in
|
in
|
||||||
verifyReturn
|
verifyReturn
|
||||||
{ idx = prevIdx + String.size strSub1 + String.size newString
|
{ idx = prevIdx + String.size strSub1 + String.size newString
|
||||||
@@ -438,9 +467,9 @@ struct
|
|||||||
(curLine - Vector.length leftLinesHd)
|
(curLine - Vector.length leftLinesHd)
|
||||||
+ Vector.length newLeftLines
|
+ Vector.length newLeftLines
|
||||||
, leftStrings = (strSub1 ^ newString) :: leftStringsTl
|
, leftStrings = (strSub1 ^ newString) :: leftStringsTl
|
||||||
, leftLines = countLineBreaks (strSub1 ^ newString) :: leftLinesTl
|
, leftLines = newLeftLines :: leftLinesTl
|
||||||
, rightStrings = strSub2 :: rightStrings
|
, rightStrings = strSub2 :: rightStrings
|
||||||
, rightLines = countLineBreaks strSub2 :: rightLines
|
, rightLines = newRightLines :: rightLines
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
else if
|
else if
|
||||||
|
|||||||
Reference in New Issue
Block a user