add debug print statements for deletion in line_gap.sml

This commit is contained in:
2024-07-15 21:48:24 +01:00
parent d8b65a5546
commit 99b1a32393

View File

@@ -947,6 +947,8 @@ struct
end end
end end
fun println str = print (str ^ "\n")
(* Delete function and helper functions for it. *) (* Delete function and helper functions for it. *)
local local
fun deleteRightFromHere fun deleteRightFromHere
@@ -991,6 +993,7 @@ struct
val newLines = val newLines =
if Vector.length rightLinesHd > 0 then if Vector.length rightLinesHd > 0 then
let let
val _ = println "996"
val lineDeleteEnd = binSearch val lineDeleteEnd = binSearch
(String.size newStr - 1, rightLinesHd) (String.size newStr - 1, rightLinesHd)
in in
@@ -1070,6 +1073,7 @@ struct
(* We can join the heads while staying in limit, so do so. *) (* We can join the heads while staying in limit, so do so. *)
let let
val newLeftStringsHd = leftStringsHd ^ rightStringsHd val newLeftStringsHd = leftStringsHd ^ rightStringsHd
val _ = println "1076"
val newLeftLinesHd: int vector = val newLeftLinesHd: int vector =
Vector.tabulate Vector.tabulate
( Vector.length leftLinesHd ( Vector.length leftLinesHd
@@ -1134,6 +1138,7 @@ struct
val newLines = val newLines =
if lineDeleteEnd >= 0 then if lineDeleteEnd >= 0 then
let let
val _ = println "1141"
val slice = VectorSlice.slice val slice = VectorSlice.slice
(rightLinesHd, 0, SOME (lineDeleteEnd + 1)) (rightLinesHd, 0, SOME (lineDeleteEnd + 1))
in in
@@ -1155,6 +1160,7 @@ struct
(* Join new string with left head. *) (* Join new string with left head. *)
let let
val newLeftStringsHd = leftStringsHd ^ newString val newLeftStringsHd = leftStringsHd ^ newString
val _ = println "1163"
val newLeftLinesHd = val newLeftLinesHd =
Vector.tabulate Vector.tabulate
( Vector.length leftLinesHd ( Vector.length leftLinesHd
@@ -1215,6 +1221,7 @@ struct
val sub1Lines = val sub1Lines =
if sub1LineEnd >= 0 then if sub1LineEnd >= 0 then
let let
val _ = println "1224"
val slice = VectorSlice.slice val slice = VectorSlice.slice
(rightLinesHd, 0, SOME (sub1LineEnd + 1)) (rightLinesHd, 0, SOME (sub1LineEnd + 1))
in in
@@ -1232,12 +1239,13 @@ struct
val sub2LineStart = forwardBinSearch (sub2Start, rightLinesHd) val sub2LineStart = forwardBinSearch (sub2Start, rightLinesHd)
val sub2Lines = val sub2Lines =
if sub2LineStart < Vector.length rightLinesHd then if sub2LineStart < Vector.length rightLinesHd then
let val _ = println "1242" in
Vector.tabulate Vector.tabulate
( Vector.length rightLinesHd - Vector.length sub1Lines ( Vector.length rightLinesHd - Vector.length sub1Lines
, fn idx => , fn idx =>
Vector.sub (rightLinesHd, idx + sub2LineStart) Vector.sub (rightLinesHd, idx + sub2LineStart)
- (String.size rightStringsHd - String.size sub2) - (String.size rightStringsHd - String.size sub2)
) ) end
else else
Vector.fromList [] Vector.fromList []
in in
@@ -1256,6 +1264,7 @@ struct
if isLeftInLimit andalso isRightInLimit then if isLeftInLimit andalso isRightInLimit then
let let
val newLeftStringsHd = leftStringsHd ^ sub1 val newLeftStringsHd = leftStringsHd ^ sub1
val _ = println "1267"
val newLeftLinesHd = val newLeftLinesHd =
Vector.tabulate Vector.tabulate
( Vector.length leftLinesHd ( Vector.length leftLinesHd
@@ -1271,6 +1280,7 @@ struct
) )
val newRightStringsHd = sub2 ^ rightStringsHd val newRightStringsHd = sub2 ^ rightStringsHd
val _ = println "1283"
val newRightLinesHd = val newRightLinesHd =
Vector.tabulate Vector.tabulate
( Vector.length rightLinesHd ( Vector.length rightLinesHd
@@ -1298,6 +1308,7 @@ struct
else if isLeftInLimit then else if isLeftInLimit then
let let
val newLeftStringsHd = leftStringsHd ^ sub1 val newLeftStringsHd = leftStringsHd ^ sub1
val _ = println "1311"
val newLeftLinesHd = val newLeftLinesHd =
Vector.tabulate Vector.tabulate
( Vector.length leftLinesHd ( Vector.length leftLinesHd
@@ -1323,6 +1334,7 @@ struct
else if isRightInLimit then else if isRightInLimit then
let let
val newRightStringsHd = sub2 ^ rightStringsHd val newRightStringsHd = sub2 ^ rightStringsHd
val _ = println "1337"
val newRightLinesHd = val newRightLinesHd =
Vector.tabulate Vector.tabulate
( Vector.length rightLinesHd ( Vector.length rightLinesHd
@@ -1375,6 +1387,7 @@ struct
val newLeftLines = val newLeftLines =
if midpoint >= 0 then if midpoint >= 0 then
let let
val _ = println "1390"
val slice = VectorSlice.slice val slice = VectorSlice.slice
(rightLinesHd, 0, SOME (midpoint + 1)) (rightLinesHd, 0, SOME (midpoint + 1))
in in
@@ -1445,6 +1458,7 @@ struct
val midpoint = binSearch (String.size newStr - 1, leftLinesHd) val midpoint = binSearch (String.size newStr - 1, leftLinesHd)
val newLines = val newLines =
let let
val _ = println "1461"
val slice = VectorSlice.slice val slice = VectorSlice.slice
(leftLinesHd, 0, SOME (midpoint + 1)) (leftLinesHd, 0, SOME (midpoint + 1))
in in
@@ -1555,6 +1569,7 @@ struct
(* Can join while staying in limit, so do join. *) (* Can join while staying in limit, so do join. *)
let let
val newRightStringsHd = leftStringsHd ^ rightStringsHd val newRightStringsHd = leftStringsHd ^ rightStringsHd
val _ = println "1572"
val newRightLinesHd = val newRightLinesHd =
Vector.tabulate Vector.tabulate
( Vector.length leftLinesHd ( Vector.length leftLinesHd
@@ -1622,6 +1637,7 @@ struct
in in
if midpoint >= 0 then if midpoint >= 0 then
let let
val _ = println "1640"
val slice = VectorSlice.slice val slice = VectorSlice.slice
(leftLinesHd, 0, SOME (midpoint + 1)) (leftLinesHd, 0, SOME (midpoint + 1))
in in
@@ -1665,8 +1681,9 @@ struct
in in
if midpoint >= 0 then if midpoint >= 0 then
let let
val _ = println "1684"
val slice = VectorSlice.slice val slice = VectorSlice.slice
(leftLinesHd, 0, SOME (midpoint + 1)) (leftLinesHd, 0, SOME (midpoint))
in in
VectorSlice.vector slice VectorSlice.vector slice
end end
@@ -1677,6 +1694,7 @@ struct
val sub2Lines = val sub2Lines =
let let
val midpoint = forwardBinSearch (sub2Start, leftLinesHd) val midpoint = forwardBinSearch (sub2Start, leftLinesHd)
val _ = println "1697"
in in
if midpoint < Vector.length leftLinesHd then if midpoint < Vector.length leftLinesHd then
Vector.tabulate Vector.tabulate
@@ -1712,6 +1730,7 @@ struct
val lines = val lines =
let let
val lineStart = forwardBinSearch (strStart, leftLinesHd) val lineStart = forwardBinSearch (strStart, leftLinesHd)
val _ = println "1733"
in in
if lineStart < Vector.length leftLinesHd then if lineStart < Vector.length leftLinesHd then
Vector.tabulate Vector.tabulate
@@ -1753,6 +1772,7 @@ struct
(* Can join while staying in limit. *) (* Can join while staying in limit. *)
let let
val newRightStringsHd = leftStringsHd ^ rightStringsHd val newRightStringsHd = leftStringsHd ^ rightStringsHd
val _ = println "1776"
val newRightLinesHd = val newRightLinesHd =
Vector.tabulate Vector.tabulate
( Vector.length leftLinesHd ( Vector.length leftLinesHd